I'm trying to debug an issue with Rails not showing the right IP, and I'd like to know how to show the headers that Rack receives from nginx, and how Rails sees them after they've been processed by all the rack middleware. Is there a straightforward way to do this within the context of a Rails 4.2.x application?
Asked
Active
Viewed 641 times
1
-
Possible duplicate of [Rack::Request - how do I get all headers?](http://stackoverflow.com/questions/6317705/rackrequest-how-do-i-get-all-headers) – Brad Werth Oct 18 '15 at 04:19
-
Not showing right IP? Share your web server configuration to find out why. – Anatoly Oct 18 '15 at 13:59
1 Answers
1
You'll be able to use the request.headers
:
#controller action
request.headers.each do |header|
header
end

Richard Peck
- 76,116
- 9
- 93
- 147
-
1This gave me all the information I needed and then some. It looks like ActionDispatch::RemoteIp::GetIp instance has an @env hash with "REMOTE_ADDR" => "127.0.0.1", "HTTP_X_FORWARDED_FOR" => "
" and tails is still using the 127.0.0.1. But that's another problem. – sockmonk Oct 19 '15 at 13:56 -
-
I think the problem is that trusted_proxies still has the internal network exclusions, in addition to the regex I gave it. Once in production it will be ok to exclude those, so I think I'm just not going to fight that battle right now. – sockmonk Oct 19 '15 at 15:49