I developed three Spring based web applications were deployed on my Tomcat 8 server. I can access them in LAN by access as:
http://localhost:8080/webapps1 http://localhost:8080/webapps2 http://localhost:8080/webapps3
which works fine for me.
Tomcat AJP connector was configured as:
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
Now I tried to publish all the three apps into Internet by using apache 2.4 proxy configure through AJP connector
I also have three FQDN were registered such as:
www.thss.domain1.com.au www.stoa.domain2.com.au ozssc.stoa.domain2.com.au
I tested those three FQDN with check-host.net, they all works fine.
Now I will configure my apache 2.4 by using proxy virtual host setting, configure file name as: apache-serviceproxy.conf in /Library/Server/Web/Config/Proxy
...... listen 10.0.1.100:80 ...... <VirtualHost 10.0.1.100:80> ProxyPreserveHost On ServerName www.thss.domain1.com.au ServerAlias thss.domain1.com.au ServerAdmin [email protected] ProxyPass / ajp://127.0.0.1:8009/webapps1/ ProxyPassReverse / ajp://127.0.0.1:8009/webapps1/ </VirtualHost> <VirtualHost 10.0.1.100:80> ProxyPreserveHost On ServerName www.stoa.domain2.com.au ServerAlias stoa.domain2.com.au ServerAdmin [email protected] ProxyPass / ajp://127.0.0.1:8009/webapps2/ ProxyPassReverse / ajp://127.0.0.1:8009/webapps2/ </VirtualHost> <VirtualHost 10.0.1.100:80> ProxyPreserveHost On ServerName ozssc.stoa.domain2.com.au ServerAdmin [email protected] ProxyPass / ajp://127.0.0.1:8009/webapps3/ ProxyPassReverse / ajp://127.0.0.1:8009/webapps3/ </VirtualHost>
Please note, FQDN 2 and 3 working in same domain (domain2.com.au) and FQDN 1 working in other domain (domain1.com.au)
I tested over internet by using net renderer.com, FQDN 1 www.thss.domain1.com.au is working beautifully, but FQDN 2 and 3 not working well, I check with my tomcat access log I found some thing is very interesting.
When I access my first FQDN (www.thss.domain1.com.au) from Internet the request pass through: Router -> Apache 2.4 (port 80) -> AJP connector (8009) -> Tomcat 8.0.28 successfully, all pages working well.
Tomcat access log shows:
184.108.40.206 - - [01/Nov/2015:09:37:40 +1100] "GET /webapps1/ HTTP/1.1" 200 2616 220.127.116.11 - - [01/Nov/2015:09:37:40 +1100] "GET /webapps1/css/thss_layout.css HTTP/1.1" 200 1405 18.104.22.168 - - [01/Nov/2015:09:37:40 +1100] "GET /webapps1/js/dojo-release-1.8.6/dojo/dojo.js HTTP/1.1" 200 158637
Such means, html request, inclusive css/js file request all using single context path /webapps1, which is perfect.
But when I request my FQDN 2 (www.stoa.domain2.com.au) and 3 (ozssc.stoa.domain2.com.au), it only first request come with correct context path such as: /webapps2 any next request on inclusive css and js or image file were double context path such as: /webapps2/webapps2, as it is not well formatted context path, Tomcat response 404 error. As result: All FQDN 2 and 3 pages with out css/js/image support, only display some plain text.
Access log shows:
22.214.171.124 - - [01/Nov/2015:08:58:59 +1100] "GET /webapps2/ HTTP/1.1" 200 19098 126.96.36.199 - - [01/Nov/2015:08:59:00 +1100] "GET /webapps2/webapps2/dojo-release-1.10.4/dijit/themes/claro/claro.css HTTP/1.1" 404 1158 188.8.131.52 - - [01/Nov/2015:08:59:01 +1100] "GET /webapps2/webapps2/css/style.css HTTP/1.1" 404 1088 184.108.40.206 - - [01/Nov/2015:08:59:02 +1100] "GET /webapps2/webapps2/images/icons/search33.png HTTP/1.1" 404 1112
My questions is: How I can configure my proxy with AJP without append that duplicated context path in the front of request from apache 2.4 to tomcat through AJP connector?
Any advice are welcome!
Have a good weekend! Mate