fabiolb / fabio

Consul Load-Balancing made simple
https://fabiolb.net
MIT License
7.27k stars 616 forks source link

Client IP is not being proxied #709

Open vesnus opened 5 years ago

vesnus commented 5 years ago

Hello!

I have Fabio as a proxy between the client and Nginx. I am trying to access client ip from inside of Nginx via variables and all the variables and all the headers return Fabio IP.

Can you please help on how I can access the client IP after traffic passed Fabio?

Tried setting proxy.header.clientip to some custom header, this doesn't work either.

Fabio version 1.5.11, fabio config is:

runtime.gogc = 800 log.access.target = stdout log.access.format = - - [] "" ".Referer" ".User-Agent" "" "" "" "" log.access.level = DEBUG log.access.target = stdout registry.consul.tagprefix = urlk8- registry.consul.kvpath = /metadata/router/config registry.consul.noroutehtmlpath = /metadata/router/noroute.html registry.consul.addr = 127.0.0.1:8500 registry.consul.token = proxy.addr = :80,:443;proto=tcp+sni proxy.maxconn = 20000 proxy.header.clientip = "X-Forwarded-For-Custom" log.level = TRACE

Thank you.

tristanmorgan commented 4 years ago

For proxy.addr = :443;proto=tcp+sni (not the :80 part) the tcp segments are opened up, checked for the SNI header then forwarded onto the backend with the data un-modified but in new segments with Fabio's IP as the source. There isn't an opportunity to add/modify the headers of the request. On the proxy.addr = :80 you should see the header being added. What are you hoping to see?

aaronhurt commented 4 years ago

@vesnus The response form @tristanmorgan is correct. If you want Fabio to inject headers you will need to do an http and/or https listener.

https://fabiolb.net/ref/proxy.addr/