I have two of my backend sockets running at port 9000 and 9001. Both provide a WebUI with CSS,JS and PHP. But both are different websites and when I use proxypass for both sites, how can I load css,js from the requested URL itself?
<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
</VirtualHost>
<VirtualHost *:443>
ServerAdmin [email protected]
ProxyRequests off
DocumentRoot /var/www/html
SSLProxyEngine on
ProxyPreserveHost On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
# ServerName _
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel error
SSLEngine on
SSLCertificateFile /path/to/crt
SSLCertificateKeyFile /path/to/key
RewriteEngine on
RewriteRule ^/site1$ /site1/ [R]
ProxyPass /site1/ https://127.0.0.1:9000/
ProxyPass /vendor/ https://127.0.0.1:9000/vendor
ProxyPass /css/ https://127.0.0.1:9000/css
ProxyRequests off
ProxyHTMLURLMap https://127.0.0.1:9000/ /site1/
ProxyHTMLExtended On
<Location /site1/>
ProxyPassReverse /
ProxyHTMLEnable On
ProxyPreserveHost On
ProxyHTMLURLMap / /site1/
RequestHeader unset Accept-Encoding
</Location>
RewriteRule ^/site2$ /site2/ [R]
ProxyPass /site2/ https://127.0.0.1:9001/
ProxyPass /vendor/ https://127.0.0.1:9001/vendor
ProxyPass /css/ https://127.0.0.1:9001/css
ProxyRequests off
ProxyHTMLURLMap https://127.0.0.1:9001/ /site2/
ProxyHTMLExtended On
<Location /site2/>
ProxyPassReverse /
ProxyHTMLEnable On
ProxyPreserveHost On
ProxyHTMLURLMap / /site2/
RequestHeader unset Accept-Encoding
</Location>
</VirtualHost>
As you can see above, I have added
ProxyPass /vendor/ https://127.0.0.1:9000/vendor
ProxyPass /css/ https://127.0.0.1:9000/css
both these lines to manually pass the CSS,vendor files to the proxy URL. But how can I make the same to site2? Since /css is added above, in site2 am getting css content from site1 itself. Also to make all hyperlinks in the site have the /site1/ and /site2/ path, I have added ProxyHTMLURLMap / /site2/ line in both of them. Its working. But no sure why CSS, JS files still go to / root path since root path doesn't have any files and give 404. How can I make these internal call CSS,JS files also take prefix /site1/ or /site2/
Without any of the ProxyHTMLURLMap / /site2/ all the links give 404 since requests go for / instead of /site2/ Same thing I want to do for CSS/JS files as well.