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