-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need to modify for AWS ELB so it will use x-forwarded-for instead of client.ip #19
Comments
Have you found how to patch it? I am not sure but I am about to try changing the occurrences of "client.ip" by "req.http.x-forwarded-for" in these 3 files: 2vcl.pl |
When looking at X-Forwarded-For, keep in mind that it may consist of more than one IP if there are upstream proxies: |
Thanks a lot @jhmartin for pointing that out, since I am behind an AWS ELB, the most recent value will be the ELB IP. I guess that using the address added before than that will be the right choice. |
The ELB won't add itself to the list (as the ELB address is the client.ip) , and the list is 'append-only' so you'll want to use the rightmost value as the client ip. |
Maybe I'm not getting this straight, look at these I tried. You can see that the last value is the ELB IP address, the one before is mine. So the ELB adds itself to the list. Right? curl --header "X-Forwarded-For:1.2.3.4" http://informe21.com/test1 curl --header "X-Forwarded-For:1.2.3.4" http://informe21.com/test2 curl --header "X-Forwarded-For:1.2.3.4" http://informe21.com/test3 |
Is this log from Vanish itself or Apache behind it? If it is Apache then it makes sense -- Varnish sees the ELB as the client and appends the ELB ip to the XFF header. If it is from varnishncsa then I am surprised and would have to look at why it is occurring that way. From an apache perspective, it should see: |
Your are right, it's from Apache behind Varnish. |
security.vcl only uses the client.ip for logging purposes at the moment, so there is no problem replacing occurences of client.ip with req.http.x-forwarded-for in your use case. |
Hernan, were you able to successfully make the modifications? Do you have the forked code somewhere we can check out? |
Have you tried to set something like this in your sub vcl_recv ruleset: remove req.http.X-Forwarded-For; |
@justnx That would make the client always appear to be the ELB itself, not the client of the ELB. |
Any tips on modification so that the x-forwaded-for IP or list of IPs are used instead of the client.ip? I am trying to implement behind a load balancer so the client.ip will look the same for every client.
The text was updated successfully, but these errors were encountered: