-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Documented the new REMOTE_ADDR option #12384
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
Conversation
deployment/proxies.rst
Outdated
@@ -44,6 +45,10 @@ and what headers your reverse proxy uses to send information:: | |||
// Request::HEADER_X_FORWARDED_AWS_ELB | |||
); | |||
|
|||
.. versionadded:: 4.4 | |||
|
|||
The support for the ``REMOTE_ADDR`` env var was introduced in Symfony 4.4. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, not envvar, maybe 'Support for the 'REMOTE_ADDR'
value was introduced...'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have a question to better understand this feature in practice. Does it work like this?
- The user defines an env var called
REMOTE_ADDR
in ....... (I don't know where) - You add the string
'REMOTE_ADDR'
here and Symfony will trust all the proxies defined in theREMOTE_ADDR
env var
Is this correct? Thanks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No :)
$_SERVER['REMOTE_ADDR']
is a value set by PHP with the IP address of the computer making the request to the server.
When you pass the string value 'REMOTE_ADDR' to setTrustedProxies it is replaced with the value of $_SERVER['REMOTE_ADDR']
. Its the same as calling setTrustedProxies($_SERVER['REMOTE_ADDR'])
. This doesnt look very helpful, but keep going...
Env vars come into this because we can make that call be setTrustedProxies($_ENV['TRUSTED_PROXIES'])
. So now we can configure trusted proxies via the env - allowing us to, for example, have different trusted proxies for dev and prod.
And we set the env var TRUSTED_PROXIES=REMOTE_ADDR
(you might do this in .env
file) - this is useful because we dont know what the IP of the proxy will be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your detailed explanation. Sadly I still don't understand anything 😓 ... but it's my fault, so don't worry. I've reworded this. Does it look better to you? Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let’s merge it 👍🏻
This PR was squashed before being merged into the 4.4 branch (closes #12384). Discussion ---------- Documented the new REMOTE_ADDR option Fixes #12382. @mcfedr @stof @nicolas-grekas please review this carefully and tell me if we should add or remove anything else from this article. Thanks! Commits ------- c8e9ff5 Documented the new REMOTE_ADDR option
Thanks Javier! I merged this as-is, as it is enough to describe the feature. However, I think the example shown in the discussions is very clear to explain why this is a usefull feature. @mcfedr are you by any chance available to submit a doc PR shortly explaining using an ENV variable for this? (I think a good place will be a |
Fixes #12382.
@mcfedr @stof @nicolas-grekas please review this carefully and tell me if we should add or remove anything else from this article. Thanks!