https://github.com/quipper/real_ip
Rack middleware to get client IP address on Heroku, extracted from our API service
https://github.com/quipper/real_ip
Last synced: over 1 year ago
JSON representation
Rack middleware to get client IP address on Heroku, extracted from our API service
- Host: GitHub
- URL: https://github.com/quipper/real_ip
- Owner: quipper
- Created: 2015-05-27T10:51:13.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2021-05-25T10:26:46.000Z (about 5 years ago)
- Last Synced: 2025-01-09T15:46:10.499Z (over 1 year ago)
- Language: Ruby
- Size: 12.7 KB
- Stars: 2
- Watchers: 218
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# RealIp
Rack middleware to get client IP address on Heroku, extracted from our API service.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'real_ip', github: 'quipper/real_ip'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install real_ip
## Usage
1. Mount `RealIp` rack middleware at the top of your Rack application's middleware stack.
Rack (`config.ru`)
```ruby
require 'real_ip'
use RealIp
```
Rails (`config/application.rb` or `config/environments/*.rb`)
```ruby
module MyApp
class Application < Rails::Application
config.middleware.insert 0, 'RealIp'
end
end
MyApp::Application.configure do
config.middleware.insert 0, 'RealIp'
end
```
2. On your controller, use `request.env['QUIPPER_REMOTE_ADDR']` to get the IP address
## Contributing
1. Fork it ( https://github.com/[my-github-username]/real_ip/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request