about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-05-31 03:30:32 +0000
committerEric Wong <e@80x24.org>2016-06-05 23:03:10 +0000
commit95807e2c3454cb4e368a521339dadc05ff4211ef (patch)
treee00f6846a3169e1e921559eee1d601603100ee61
parent4504b6968e340fa4487524ac7a12f605a0361e56 (diff)
downloadyahns-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.rb5
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