dimanche 23 juillet 2017

How to redirect to different AJP connector based on server name only (same context path)



When you have two domains pointing to the same IP address, how to server different page only based on the URL.

Setup 2 tomcat listening on AJP port 8019 and 8009

- declare two domains on you DNS page

Then modify the apache configuration as follow.



NameVirtualHost *:80
ProxyPreserveHost On

ProxyPass  /  ajp://localhost:8009/
ProxyPassReverse /  ajp://localhost:8009/
ServerName virtualserver1.mydomain.com



ServerName virtualserver2.mydomain.com
ProxyPass / ajp://localhost:8019/
ProxyPassReverse /  ajp://localhost:8019/