Monday, 28 September 2020

Running Symfony 5 with reverse proxy in subdirectory

I like to run a Symfony 5 application behind a reverse proxy which supplies the following endpoint:

https://my.domain/service1/

The proxy config basically is this:

ProxyPass /marketsy/ http://internal.service1/

On the server the reverse proxy is connecting to, I use the following apache rule for serving my Symfony application:

<VirtualHost *:80>
  ServerName internal.service1
  DocumentRoot /webroot/service1/public

 <FilesMatch \.php$>
     SetHandler proxy:unix:/run/php/php7.2-fpm-ui.sock|fcgi://localhost
     SetEnvIfNoCase ^Authorization$ "(.+)" HTTP_AUTHORIZATION=$1
     SetEnv HTTP_X_FORWARDED_PROTO "https"
 </FilesMatch>

 <Directory  /webroot/service1/public>
     AllowOverride None
     Require all granted
     FallbackResource /index.php
 </Directory>

 <Directory  /webroot/service1/public/bundles>
     FallbackResource disabled
 </Directory>
</VirtualHost>

The application itself is reqachable but Symfony can't hanle the "service1" path prefix.

For example it tries to access the profiler under https://my.domain/_wdt/8e3926 instead of https://my.domain/service1/_wdt/8e3926 and beside the root route all the routing isn't working:

For example: When I try to access https://my.domain/service1/my/page i will get redirected to https://my.domain/my/page

Now my question is, how can I configure Symfony to know about the "service1" path prefix when generation urls ets.



from Running Symfony 5 with reverse proxy in subdirectory

No comments:

Post a Comment