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

Allow nginx to set REMOTE_ADDR #354

Merged
merged 1 commit into from Apr 22, 2018
Merged

Allow nginx to set REMOTE_ADDR #354

merged 1 commit into from Apr 22, 2018

Conversation

nrwiersma
Copy link
Contributor

As it stands, when proxying with nginx, REMOTE_ADDR will always be 127.0.0.1. While it is possible to set and use X_REAL_IP or the like, existing software that depends on REMOTE_ADDR will have problems.

The solution proposed was inspired by php-fpm handling, where REMOTE_ADDR and REMOTE_PORT are set. However in an nginx proxy environment HTTP_ is prepended to the $_SERVER variable.

@andig
Copy link
Contributor

andig commented Apr 14, 2018

ping @marcj lgtm- what do you think?

@marcj
Copy link
Member

marcj commented Apr 14, 2018

My question remains open

@nrwiersma
Copy link
Contributor Author

What question is that?

@andig
Copy link
Contributor

andig commented Apr 16, 2018

While waiting for marc's question I'm wondering if we shouldn't rather set the x-forwarded-* headers instead of faking REMOTE_ADDR. This should be in line with https://symfony.com/doc/current/deployment/proxies.html.
If doing so we should however only relay x-forwarded-* headers to the client if they are coming from a trusted proxy, i.e. we'd need another config option for that plus use something like Symfony Router/Matcher for checking proxy validity.

Am I making sense here?

@nrwiersma
Copy link
Contributor Author

I completely understand what you mean.

We did it this way to keep applications already using REMOTE_ADDR from FPM and nginx working. It is a fairly common use case to pass this info into REMOTE_ADDR from niginx, one that FPM allows. Also with X-FORWARDED-* you have to be careful to append and not overwrite.

@andig andig merged commit d1dd43f into php-pm:master Apr 22, 2018
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

Successfully merging this pull request may close these issues.

None yet

3 participants