I have spent quite some time trying to figure out something apparentaly pretty trivial, but my lack of knowledge in Apache/Tomcat isn't making this easy for me.
I was asked to redirect a request coming on port 80 (Apache) to port 8080 (Tomcat.. and when that will work, to an app).
Before I changed anything, localhost:80 would show "It works" and locahost:8080 the Apache welcome page.
I did the following changes :
- uncommented LoadModule proxy_module modules/mod_proxy.so & LoadModule proxy_http_module modules/mod_proxy_http.so from the httpd.conf file
- uncommented Include conf/extra/httpd-vhosts.conf, always in httpd.conf
In httpd-vhosts.conf, I added :
<VirtualHost *:80>
ServerName localhost
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:8080
ProxyPassReverse / http://localhost:8080
</VirtualHost>
But when I try http://localhost, I do arrive on Apache welcome page, but all css styling, images, are missing :
I have an idea why it is not working : when I inspect my page, and look at the header i see that the link to the favicon for example is http://mydomain/myApp/images/favicon.ico, but if I copy paste that link, I will of course not find the favicon because it is not on Apache, but Tomcat (if that makes any sense). If I add the port to the URL, then it works : http://mydomain:8080/myApp/images/favicon.ico
Has this anything to do with the problem stated here : https://serverfault.com/questions/561892/how-to-handle-relative-urls-correctly-with-a-reverse-proxy ?
This is because the tomcat response headers will contain the proxy headers (i.e. the Location header is http://localhost/WebApp rather than http://localhost:8080/WebApp) because ProxyPreserveHost is switched On
So I switched it to Off :
<VirtualHost *:80>
ServerName localhost
ProxyRequests Off
ProxyPreserveHost Off
ProxyPass / http://localhost:8080
ProxyPassReverse / http://localhost:8080
</VirtualHost>
But the page still will not show correctly.
Thank you for your input.
