Please help me with the following problem on which I'm stuck for weeks now.
As I can't use subdomains and also can't access other Ports then 80 and 443, I have to proxy several services to subdirectories of my domain. The services are either running on the webserver itself (under different ports, obviously) or on other machines in the same lan (perhaps other ports too).
Goal is:
example.com/app1 => localhost:8080
example.com/app2 => localhost:4711
example.com/app3 => 2nd-machine
example.com/app4 => 3rd-machine:8000
(Everything that won't be proxied should be rewritten to HTTPS at the end, but I got that. But if it's a neccessary piece of information - now you have it.)
I tried several different approaches already over the last couple of weeks, including different combinations of ProxyPass(Reverse) and RewriteRules.
Problem is, that the main pages are shown (improperly), but alle the images, the CSS and so on are missing and the links are not working. I would like to have fully proxied websites available under subdirectories of the domain.
I can't give you code for all the things I've already tried, but here are some of the combinations, I've already tried:
<VirtualHost 192.168.x.y:80>
ServerName example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^/solar-log(.*) http://192.168.x.z$1 [P,L]
ProxyPassReverse /solar-log/ http://192.168.x.z
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^/solar-log/(.*) http://192.168.x.z/$1 [P,QSA]
ProxyPassReverse /solar-log http://192.168.x.z
RewriteRule ^/rhasspy/(.*) http://localhost:4711/$1 [P,L]
RewriteRule ^/rhasspy/(js|img|css)(.*) http://localhost:4711/$1$1 [P]
ProxyPass /rhasspy http://localhost:4711/
ProxyPassReverse /rhasspy/ http://localhost:4711
ProxyPassReverseCookiePath / /rhasspy
ProxyPassReverseCookieDomain localhost localhost
ProxyPass / http://localhost:4711/
ProxyPassReverse / http://localhost:4711/
RewriteRule ^/$ /rhasspy/ [P,L]
# Redirect to HTTPS, except the URIs, that point to other servers/services, that don't have HTTPS
RewriteCond %{SERVER_NAME} =example.com
RewriteCond %{REQUEST_URI} !^/solar-log [NC]
RewriteCond %{REQUEST_URI} !^/rhasspy [NC]
RewriteCond %{REQUEST_URI} !^/home-assistant [NC]
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [NE,R=permanent]
#RewriteBase "/solar-log/"
RewriteRule ^/solar-log(.*) http://192.168.x.z$1 [P,QSA]
ProxyPassReverse /solar-log http://192.168.x.z
RewriteRule ^/(.*) http://127.0.0.1/$1 [P,L]
ProxyPassReverse / http://127.0.0.1
<Location /solar-log>
ProxyPass http://192.168.x.z
ProxyPassReverse http://192.168.x.z
</Location>
ProxyPreserveHost On
ProxyPass /airsonic http://localhost:8080
ProxyPassReverse /airsonic http://localhost:8080
ProxyPass /rhasspy/ http://localhost:4711/
ProxyPassReverse /rhasspy/ http://localhost:4711/
ProxyPass /home-assistant http://localhost:8000
ProxyPassReverse /home-assistant http://localhost:8000
</VirtualHost>
The closest was this configuration, after this tutorial: http://www.apachetutor.org/admin/reverseproxies
<VirtualHost 192.168.x.y:80>
ServerName example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyRequests off
ProxyPass /rhasspy/ http://127.0.0.1:4711/
ProxyHTMLURLMap http://127.0.0.1:4711/ /rhasspy
ProxyPass /solar-log/ http://solar-log/
ProxyHTMLURLMap http://solar-log/ /solar-log/
<Location /rhasspy/>
ProxyPassReverse /
ProxyHTMLEnable On
ProxyHTMLExtended On
ProxyHTMLURLMap / /rhasspy/
RequestHeader unset Accept-Encoding
</Location>
<Location /solar-log/>
ProxyPassReverse /
ProxyHTMLEnable On
ProxyHTMLExtended On
ProxyHTMLURLMap / /solar-log/
RequestHeader unset Accept-Encoding
</Location>
</VirtualHost>
With that configuration, the websites loaded a bit more content, but did't really work in the end (combo boxes where empty/had no data in them, some internal stuff didn't work and produced error messages, and so on...)
I've already read dozens of other questions and tutorials, but none of them led me to success. For example: Apache as reverse proxy for multiple destinations and one default destination
So I'm stuck.
Any help appreciated.
Thanks.