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