8000 Documented the new REMOTE_ADDR option by javiereguiluz · Pull Request #12384 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

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

Merged
merged 1 commit into from
Nov 9, 2019
Merged

Conversation

javiereguiluz
Copy link
Member

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!

@@ -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.
Copy link
Contributor

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...'

Copy link
Member Author

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 the REMOTE_ADDR env var

Is this correct? Thanks.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor
@mcfedr mcfedr Sep 27, 2019

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.

Copy link
Member Author

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

@javiereguiluz javiereguiluz changed the title Documented the new REMOTE_ADDR env var Documented the new REMOTE_ADDR option Sep 27, 2019
Copy link
Contributor
@OskarStark OskarStark left a 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 👍🏻

wouterj added a commit that referenced this pull request Nov 9, 2019
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
@wouterj wouterj merged commit c8e9ff5 into symfony:4.4 Nov 9, 2019
@wouterj
Copy link
Member
wouterj commented Nov 9, 2019

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 .. tip:: just below this example)

@mcfedr
Copy link
Contributor
mcfedr commented Nov 12, 2019

@wouterj Something like #12622 ?

OskarStark added a commit that referenced this pull request Nov 14, 2019
This PR was submitted for the master branch but it was merged into the 4.3 branch instead (closes #12622).

Discussion
----------

Add tip for trusted_proxies

Continuing on from #12384, a quick tip to help the flex user

Commits
-------

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

Successfully merging this pull request may close these issues.

6 participants
0