diff options
author | Eric Wong <e@80x24.org> | 2016-05-31 03:30:32 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2016-06-05 23:03:10 +0000 |
commit | 95807e2c3454cb4e368a521339dadc05ff4211ef (patch) | |
tree | e00f6846a3169e1e921559eee1d601603100ee61 | |
parent | 4504b6968e340fa4487524ac7a12f605a0361e56 (diff) | |
download | yahns-95807e2c3454cb4e368a521339dadc05ff4211ef.tar.gz |
Ugh, this is a little slower, but some people will want to forward through multiple proxies.
-rw-r--r-- | lib/yahns/proxy_pass.rb | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/yahns/proxy_pass.rb b/lib/yahns/proxy_pass.rb index 148957b..eb48647 100644 --- a/lib/yahns/proxy_pass.rb +++ b/lib/yahns/proxy_pass.rb @@ -226,9 +226,12 @@ class Yahns::ProxyPass # :nodoc: 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 |