diff --git a/lib/puma/binder.rb b/lib/puma/binder.rb index 5931fe2e..a622bab3 100644 --- a/lib/puma/binder.rb +++ b/lib/puma/binder.rb @@ -288,6 +288,10 @@ module Puma File.chmod mode, path end + env = @proto_env.dup + env[REMOTE_ADDR] = "127.0.0.1" + @envs[s] = env + s end @@ -301,6 +305,10 @@ module Puma end @ios << s + env = @proto_env.dup + env[REMOTE_ADDR] = "127.0.0.1" + @envs[s] = env + s end diff --git a/lib/puma/server.rb b/lib/puma/server.rb index dd7d1f2b..b731bd3d 100644 --- a/lib/puma/server.rb +++ b/lib/puma/server.rb @@ -456,12 +456,14 @@ module Puma # intermediary acting on behalf of the actual source client." # - addr = client.peeraddr.last + unless env.key?(REMOTE_ADDR) + addr = client.peeraddr.last - # Set unix socket addrs to localhost - addr = "127.0.0.1" if addr.empty? + # Set unix socket addrs to localhost + addr = "127.0.0.1" if addr.empty? - env[REMOTE_ADDR] = addr + env[REMOTE_ADDR] = addr + end end def default_server_port(env)