@@ -157,6 +157,35 @@ enough, as it will only trust the node sitting directly above your application
157
157
ranges of any additional proxy (e.g. `CloudFront IP ranges `_) to the array of
158
158
trusted proxies.
159
159
160
+ Reverse proxy in a subpath / subfolder
161
+ --------------------------------------
162
+
163
+ If your Symfony application runs behind a reverse proxy and it's served in a
164
+ subpath/subfolder, Symfony might generate incorrect URLs that ignore the
165
+ subpath/subfolder of the reverse proxy.
166
+
167
+ To fix this, you need to pass the subpath/subfolder route prefix of the reverse
168
+ proxy to Symfony by setting the ``X-Forwarded-Prefix `` header. The header can
169
+ normally be configured in your reverse proxy configuration. Configure
170
+ ``X-Forwared-Prefix `` as trusted header to be able to use this feature.
171
+
172
+ The ``X-Forwarded-Prefix `` is used by Symfony to prefix the base URL of request
173
+ objects, which is used to generate absolute paths and URLs in Symfony applications.
174
+ Without the header, the base URL would be only determined based on the configuration
175
+ of the web server running Symfony, which leads to incorrect paths/URLs, when the
176
+ application is served under a subpath/subfolder by a reverse proxy.
177
+
178
+ For example if your Symfony application is directly served under a URL like
179
+ ``https://symfony.tld/ `` and you would like to use a reverse proxy to serve the
180
+ application under ``https://public.tld/app/ ``, you would need to set the
181
+ ``X-Forwarded-Prefix `` header to ``/app/ `` in your reverse proxy configuration.
182
+ Without the header, Symfony would generate URLs based on its server base URL
183
+ (e.g. ``/my/route ``) instead of the correct ``/app/my/route ``, which is
184
+ required to access the route via the reverse proxy.
185
+
186
+ The header can be different for each reverse proxy, so that access via different
187
+ reverse proxies served under different subpaths/subfolders can be handled correctly.
188
+
160
189
Custom Headers When Using a Reverse Proxy
161
190
-----------------------------------------
162
191
0 commit comments