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

Set a default REMOTE_ADDR to avoid using peeraddr on unix sockets. Fixes #583

This commit is contained in:
Evan Phoenix 2015-01-20 10:34:14 -08:00
parent cc4ad17519
commit 9fc65acee7
2 changed files with 14 additions and 4 deletions

View file

@ -288,6 +288,10 @@ module Puma
File.chmod mode, path File.chmod mode, path
end end
env = @proto_env.dup
env[REMOTE_ADDR] = "127.0.0.1"
@envs[s] = env
s s
end end
@ -301,6 +305,10 @@ module Puma
end end
@ios << s @ios << s
env = @proto_env.dup
env[REMOTE_ADDR] = "127.0.0.1"
@envs[s] = env
s s
end end

View file

@ -456,6 +456,7 @@ module Puma
# intermediary acting on behalf of the actual source client." # intermediary acting on behalf of the actual source client."
# #
unless env.key?(REMOTE_ADDR)
addr = client.peeraddr.last addr = client.peeraddr.last
# Set unix socket addrs to localhost # Set unix socket addrs to localhost
@ -463,6 +464,7 @@ module Puma
env[REMOTE_ADDR] = addr env[REMOTE_ADDR] = addr
end end
end
def default_server_port(env) def default_server_port(env)
env['HTTP_X_FORWARDED_PROTO'] == 'https' ? PORT_443 : PORT_80 env['HTTP_X_FORWARDED_PROTO'] == 'https' ? PORT_443 : PORT_80