Ugh, this is a little slower, but some people will want to
forward through multiple proxies.
---
lib/yahns/proxy_pass.rb | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/yahns/proxy_pass.rb b/lib/yahns/proxy_pass.rb
index 8e0b742..a30089d 100644
--- a/lib/yahns/proxy_pass.rb
+++ b/lib/yahns/proxy_pass.rb
@@ -59,9 +59,12 @@ def call(env)
ver = 'HTTP/1.0'.freeze
end
+ addr = env['REMOTE_ADDR']
+ xff = env['HTTP_X_FORWARDED_FOR']
+ xff = xff =~ /\S/ ? "#{xff}, #{addr}" : addr
req = "#{env['REQUEST_METHOD']} #{req} #{ver}\r\n" \
"X-Forwarded-Proto: #{env['rack.url_scheme']}\r\n" \
- "X-Forwarded-For: #{env["REMOTE_ADDR"]}\r\n".dup
+ "X-Forwarded-For: #{xff}\r\n".dup
# pass most HTTP_* headers through as-is
chunked = false
--
unsubscribe: [email protected]
archive: https://yhbt.net/yahns-public/