@@ -165,14 +165,24 @@ Reverse proxy in a subpath / subfolder
165
165
If you configure the reverse proxy in such a way that the Symfony application is
166
166
mapped in a subpath / subfolder instead of the root path of the web host, you will need to
167
167
pass the prefix to Symfony by setting the ``X-Forwarded-Prefix `` header.
168
- This is required for Symfony to generate the correct URLs.
169
-
170
- This can normally be configured in your reverse proxy configuration.
171
- If the application is served via the reverse proxy under a URL like
172
- ``https://localhost/app/ ``, then ``X-Forwarded-Prefix `` must be set to ``/app/ `` by the
173
- reverse proxy. Be sure that ``X-Forwared-Prefix `` is configured as trusted header, if
168
+ This is required for Symfony to generate the correct URLs. The header can normally be configured
169
+ in your reverse proxy configuration. Be sure that ``X-Forwared-Prefix `` is configured as trusted header, if
174
170
you want to use this feature.
175
171
172
+ The ``X-Forwarded-Prefix `` is used by Symfony to prefix the base URL of request objects, which is
173
+ used to generate absolute paths and URLs in Symfony applications. Without the header, the base URL would be only determined
174
+ based on the configuration of the web server running Symfony, which leads to incorrect pathes/URLs, when the application
175
+ is served under a subpath by a reverse proxy.
176
+
177
+ For example if your symfony application is directly served under an URL like ``https://symfony.tld/ ``
178
+ and you would like to use a reverse proxy to serve the application under ``https://public.tld/app/ ``, you would need
179
+ to set the ``X-Forwarded-Prefix `` header to ``/app/ `` in your reverse proxy configuration.
180
+ Without the header, Symfony would generate URLs based on its servers base URL (e.g. ``/my/route ``) instead of the correct
181
+ ``/app/my/route ``, which is required to access the route via the reverse proxy.
182
+
183
+ The header can be different for each reverse proxy, so that access via different reverse proxies served under different
184
+ subpaths can be handled correctly.
185
+
176
186
Custom Headers When Using a Reverse Proxy
177
187
-----------------------------------------
178
188
0 commit comments