Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
Documented how to configure Symfony correctly with regards to the Forwarded header#6526
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -23,7 +23,7 @@ via HTTPS, the client's port and the hostname being requested. | ||
| Solution: trusted_proxies | ||
| ------------------------- | ||
| This is no problem, but you *do* need to tell Symfonywhat is happening | ||
| and which reverse proxy IP addresses will be doing this type of thing: | ||
| .. configuration-block:: | ||
| @@ -62,6 +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. | ||
| You are also saying that you trust that the proxy does not send conflicting | ||
| headers, e.g. sending both X-Forwarded-For and Forwarded in the same request. | ||
| 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. | ||
| @@ -95,6 +98,29 @@ That's it! It's critical that you prevent traffic from all non-trusted sources. | ||
| If you allow outside traffic, they could "spoof" their true IP address and | ||
| other information. | ||
| .. _cookbook-request-untrust-header: | ||
| My Reverse Proxy Sends X-Forwarded-For but does not Filter the Forwarded Header | ||
| ------------------------------------------------------------------------------- | ||
| Many popular proxy implementations do not yet support the Forwarded header and | ||
| do not filter it by default. Ideally, you would configure this | ||
| in your proxy. If this is not possible, you can tell Symfony to distrust | ||
| the Forwarded header, while still trusting your proxy's X-Forwarded-For header. | ||
| This is done inside of your front controller:: | ||
| // web/app.php | ||
| // ... | ||
| Request::setTrustedHeaderName(Request::HEADER_FORWARDED, null); | ||
Member 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. previously, we set it to ContributorAuthor 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. Agreed | ||
| $response = $kernel->handle($request); | ||
| // ... | ||
| Configuring the proxy server trust is very important, as not doing so will | ||
| malicious users to "spoof" their IP address. | ||
| My Reverse Proxy Uses Non-Standard (not X-Forwarded) Headers | ||
| ------------------------------------------------------------ | ||