Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

:facepalm: Request#remote_ip has to work without the middleware

  • Loading branch information...
commit 5621abd5698536f1676306930f6aef105d7ae6dc 1 parent f05ccf8
@indirect indirect authored
View
4 actionpack/lib/action_dispatch/http/request.rb
@@ -155,9 +155,9 @@ def ip
@ip ||= super
end
- # Originating IP address from the RemoteIp middleware.
+ # Originating IP address, usually set by the RemoteIp middleware.
def remote_ip
- @remote_ip ||= @env["action_dispatch.remote_ip"]
+ @remote_ip ||= @env["action_dispatch.remote_ip"] || ip
end
# Returns the unique request id, which is based off either the X-Request-Id header that can
View
2  actionpack/lib/action_dispatch/middleware/remote_ip.rb
@@ -58,7 +58,7 @@ def calculate_ip
not_proxy = client_ip || forwarded_ips.last || remote_addrs.first
# Return first REMOTE_ADDR if there are no other options
- not_proxy || ips_from('REMOTE_ADDR', :all).first
+ not_proxy || ips_from('REMOTE_ADDR', :allow_proxies).first
end
def to_s
Please sign in to comment.
Something went wrong with that request. Please try again.