-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Added support for standard Forwarded header #4266
Closed
+16
−8
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,9 +7,14 @@ an AWS Elastic Load Balancer) or a reverse proxy (e.g. Varnish for | |
|
||
For the most part, this doesn't cause any problems with Symfony. But, when | ||
a request passes through a proxy, certain request information is sent using | ||
special ``X-Forwarded-*`` headers. For example, instead of reading the ``REMOTE_ADDR`` | ||
header (which will now be the IP address of your reverse proxy), the user's | ||
true IP will be stored in an ``X-Forwarded-For`` header. | ||
either the standard ``Forwarded`` header or non standard special ``X-Forwarded-*`` | ||
headers. For example, instead of reading the ``REMOTE_ADDR`` header (which | ||
will now be the IP address of your reverse proxy), the user's true IP will be | ||
stored in a standard ``Forwarded: for="..."`` header or a non standard | ||
``X-Forwarded-For`` header. | ||
|
||
.. versionadded:: 2.7 | ||
``Forwarded`` header support was introduced in Symfony 2.7 | ||
|
||
If you don't configure Symfony to look for these headers, you'll get incorrect | ||
information about the client's IP address, whether or not the client is connecting | ||
|
@@ -57,9 +62,9 @@ the IP address ``192.0.0.1`` or matches the range of IP addresses that use | |
the CIDR notation ``10.0.0.0/8``. For more details, see the | ||
:ref:`framework.trusted_proxies <reference-framework-trusted-proxies>` option. | ||
|
||
That's it! Symfony will now look for the correct ``X-Forwarded-*`` headers | ||
to get information like the client's IP address, host, port and whether or | ||
not the request is using HTTPS. | ||
That's it! Symfony will now look for the correct headers to get information | ||
like the client's IP address, host, port and whether the request is | ||
using HTTPS. | ||
|
||
But what if the IP of my Reverse Proxy Changes Constantly! | ||
---------------------------------------------------------- | ||
|
@@ -90,9 +95,12 @@ other information. | |
My Reverse Proxy Uses Non-Standard (not X-Forwarded) Headers | ||
------------------------------------------------------------ | ||
|
||
Most reverse proxies store information on specific ``X-Forwarded-*`` headers. | ||
But if your reverse proxy uses non-standard header names, you can configure | ||
Although `rfc7239`_ recently defined a standard ``Forwarded`` header to disclose | ||
all proxy information, most reverse proxies store information on non standard | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should be "non-standard" (same on line 10) |
||
``X-Forwarded-*`` headers. | ||
But if your reverse proxy uses other non-standard header names, you can configure | ||
these (see ":doc:`/components/http_foundation/trusting_proxies`"). | ||
The code for doing this will need to live in your front controller (e.g. ``web/app.php``). | ||
|
||
.. _`security groups`: http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/using-elb-security-groups.html | ||
.. _`rfc7239`: http://tools.ietf.org/html/rfc7239 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
this should be "RFC 7239"