1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

When using a header for the remote address, use the first word only

This commit is contained in:
Evan Phoenix 2016-01-06 10:33:50 -08:00
parent d5914573c9
commit 5ce24bf7c2
2 changed files with 5 additions and 2 deletions

View file

@ -309,7 +309,7 @@ module Puma
return @peerip if @peerip
if @remote_addr_header
hdr = @env[@remote_addr_header] || LOCALHOST_ADDR
hdr = (@env[@remote_addr_header] || LOCALHOST_ADDR).split(" ").first
@peerip = hdr
return hdr
end

View file

@ -310,7 +310,10 @@ module Puma
# * :localhost - set the remote address to "127.0.0.1"
# * header: http_header - set the remote address to the value of the
# provided http header. For instance:
# `set_remote_address header: "X-Real-IP"`
# `set_remote_address header: "X-Real-IP"`.
# Only the first word (as separated by spaces)
# is used, allowing headers such as X-Forwarded-For
# to be used as well.
# * Any string - this allows you to hardcode remote address to any value
# you wish. Because puma never uses this field anyway, it's
# format is entirely in your hands.