I'm trying to configure on Apache a subdomain that should:
- Serve a PHP Laravel app if the request starts with /backoffice
- ReverseProxy to a node app otherwise.
I can configure the reverse proxy and the Laravel independently but not at the same time as the .htaccess on Laravel public folder conflicts with the reverse proxy configurations.
Here's the .htaccess on laravel folder:
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
And here's the relevant part of the configuration of the apache conf file:
Alias /backoffice /mnt/volume_fra1_01/project/backoffice/public
<Directory /mnt/volume_fra1_01/project/backoffice/public >
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ProxyRequests On
ProxyPass /backoffice !
ProxyPass / http://localhost:3000
ProxyPassReverse / http://localhost:3000
Even with the /backoffice exclusion every request gets to the reverse proxy.
By removing the .htaccess I can confirm that the exclusion is actually happening. So I suspect that modrewrite is messing with the URI in such a way that it gets caught by the ProxyPass rule.
This configurations seems like something that should be easy to accomplish. And it is very easy to do in NGINX. How can I do it in Apache?