Skip to content

Commit 392d0d9

Browse files
authored
Suggest Flex config for more traditional infrastructure
1 parent aef616b commit 392d0d9

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

deployment/proxies.rst

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,23 @@ and what headers your reverse proxy uses to send information:
8888
to trust all "X-Forwarded-" headers, but that constant is deprecated since
8989
Symfony 5.2 in favor of the individual ``HEADER_X_FORWARDED_*`` constants.
9090

91+
.. tip::
92+
93+
In applications using :ref:`Symfony Flex <symfony-flex>` you can set the
94+
``TRUSTED_PROXIES`` env var:
95+
96+
.. code-block:: bash
97+
98+
# .env
99+
TRUSTED_PROXIES=127.0.0.1
100+
101+
.. code-block:: yaml
102+
103+
# config/packages/framework.yaml
104+
framework:
105+
# ...
106+
trusted_proxies: '%env(TRUSTED_PROXIES)%'
107+
91108
.. caution::
92109

93110
Enabling the ``Request::HEADER_X_FORWARDED_HOST`` option exposes the
@@ -136,23 +153,6 @@ That's it! It's critical that you prevent traffic from all non-trusted sources.
136153
If you allow outside traffic, they could "spoof" their true IP address and
137154
other information.
138155

139-
.. tip::
140-
141-
In applications using :ref:`Symfony Flex <symfony-flex>` you can set the
142-
``TRUSTED_PROXIES`` env var:
143-
144-
.. code-block:: bash
145-
146-
# .env
147-
TRUSTED_PROXIES=127.0.0.1,REMOTE_ADDR
148-
149-
.. code-block:: yaml
150-
151-
# config/packages/framework.yaml
152-
framework:
153-
# ...
154-
trusted_proxies: '%env(TRUSTED_PROXIES)%'
155-
156156
If you are also using a reverse proxy on top of your load balancer (e.g.
157157
`CloudFront`_), calling ``$request->server->get('REMOTE_ADDR')`` won't be
158158
enough, as it will only trust the node sitting directly above your application

0 commit comments

Comments
 (0)