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:
88
88
to trust all "X-Forwarded-" headers, but that constant is deprecated since
89
89
Symfony 5.2 in favor of the individual ``HEADER_X_FORWARDED_* `` constants.
90
90
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
+
91
107
.. caution ::
92
108
93
109
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.
136
152
If you allow outside traffic, they could "spoof" their true IP address and
137
153
other information.
138
154
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
-
156
155
If you are also using a reverse proxy on top of your load balancer (e.g.
157
156
`CloudFront `_), calling ``$request->server->get('REMOTE_ADDR') `` won't be
158
157
enough, as it will only trust the node sitting directly above your application
You can’t perform that action at this time.
0 commit comments