Skip to content
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

Use $proxy_add_x_forwarded_for in nginx template for X-Forwarded-For header #167

Closed
icpz opened this issue Jul 23, 2019 · 2 comments
Closed

Comments

@icpz
Copy link

icpz commented Jul 23, 2019

Hello, I'm in situation to put docker services behind a custom nginx frontend.
This frontend will set the correct X-Forwarded-For header, but it's override by the nginx inside the docker image here.

Could you please replace that line with:

    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

This will prevent the existing X-Forwarded-For from being changed, and set it to $remote_addr if not exist.

@renfeipeng
Copy link
Contributor

Thank you for your suggestion, we will improve this configuration on the next release.

@Redsandro
Copy link

I think it would make sense to replace all X-Forwarded headers:

-        proxy_set_header Forwarded "for=$remote_addr;proto=$scheme";
+        proxy_set_header Forwarded "for=$proxy_add_x_forwarded_for;proto=$http_x_forwarded_proto";
-        proxy_set_header X-Forwarded-For $remote_addr;
+        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-        proxy_set_header X-Forwarded-Proto $scheme;
+        proxy_set_header X-Forwarded-Proto $http_x_forwarded_proto;
-        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header X-Real-IP $proxy_add_x_forwarded_for;

See #91 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants