* [PATCH] proxy_pass: X-Forwarded-For appends to existing list
@ 2016-05-31 4:18 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2016-05-31 4:18 UTC (permalink / raw)
To: yahns-public
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-05-31 4:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-31 4:18 [PATCH] proxy_pass: X-Forwarded-For appends to existing list Eric Wong
Code repositories for project(s) associated with this public inbox
http://yhbt.net/yahns.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).