File tree Expand file tree Collapse file tree 1 file changed +16
-17
lines changed Expand file tree Collapse file tree 1 file changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,22 @@ 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+ You can set a ``TRUSTED_PROXIES `` env var to configure proxies on a per-environment basis:
94+
95+ .. code-block :: bash
96+
97+ # .env
98+ TRUSTED_PROXIES=127.0.0.1,10.0.0.0/8
99+
100+ .. code-block :: yaml
101+
102+ # config/packages/framework.yaml
103+ framework :
104+ # ...
105+ trusted_proxies : ' %env(TRUSTED_PROXIES)%'
106+
91107 .. caution ::
92108
93109 Enabling the ``Request::HEADER_X_FORWARDED_HOST `` option exposes the
@@ -136,23 +152,6 @@ That's it! It's critical that you prevent traffic from all non-trusted sources.
136152If you allow outside traffic, they could "spoof" their true IP address and
137153other information.
138154
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-
156155If you are also using a reverse proxy on top of your load balancer (e.g.
157156`CloudFront `_), calling ``$request->server->get('REMOTE_ADDR') `` won't be
158157enough, as it will only trust the node sitting directly above your application
You can’t perform that action at this time.
0 commit comments