I have a WordPress site running in a server where now I need to deploy a web app on and since our SSL certificate is not wildcard it has to be under the same domain name too. Now it's running on a different port but users are complaining that is not that friendly to access.
I've setup a reverse proxy because the app is run by another service on the same machine, but when the request is returned to the user it looses the first part of the URL so it ends up on a 404 error.
The WordPress site is running on www.example.com
and the web app should be on www.example.com/app
but when the request gets back the url looks like www.example.com/Identity...
instead of www.example.com/app/Identity...
This is the Virtual Host configuration and the htaccess I'm using in WordPress to allow the /app pass through WordPress routing. I've tried using ProxyPassReverse but it's not working and using mod_rewrite is not an option because the urls from the web app not always start with the same string.
VirtualHost:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin webmaster@localhost
ServerName www.example.com
DocumentRoot /var/www/html
ProxyPreserveHost On
ProxyRequests Off
ProxyPass /app http://localhost:5000
ProxyPassReverse /app http://localhost:5000/app/
Header unset X-Frame-Options
LogLevel trace3
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/cert.pem
SSLCertificateKeyFile /etc/apache2/ssl/private.key
SSLCertificateChainFile /etc/apache2/ssl/intermediate.pem
<FilesMatch "\.(cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
</IfModule>
Htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/app.*$ [NC]
RewriteRule . - [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Thanks in advance!