Log the remote IP addr of clients behind a proxy

[Atul Bhosale, Victor Nawothnig]
This commit is contained in:
Atul Bhosale 2018-07-31 20:09:42 +05:30
parent 0f5497499c
commit 7e40e9585a
2 changed files with 7 additions and 1 deletions

View File

@ -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

View File

@ -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