mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Log the remote IP addr of clients behind a proxy
[Atul Bhosale, Victor Nawothnig]
This commit is contained in:
parent
0f5497499c
commit
7e40e9585a
2 changed files with 7 additions and 1 deletions
|
@ -50,7 +50,7 @@ module Rails
|
|||
'Started %s "%s" for %s at %s' % [
|
||||
request.request_method,
|
||||
request.filtered_path,
|
||||
request.ip,
|
||||
request.remote_ip,
|
||||
Time.now.to_default_s ]
|
||||
end
|
||||
|
||||
|
|
|
@ -53,6 +53,12 @@ module ApplicationTests
|
|||
wait
|
||||
assert_match 'Started HEAD "/"', logs
|
||||
end
|
||||
|
||||
test "logger logs correct remote IP address" do
|
||||
get "/", {}, { "REMOTE_ADDR" => "127.0.0.1", "HTTP_X_FORWARDED_FOR" => "1.2.3.4" }
|
||||
wait
|
||||
assert_match 'Started GET "/" for 1.2.3.4', logs
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue