views:

496

answers:

1

Hi,

I have a problem configuring apache tomcat ProxyPass directive for two applications that have two different Contaxt Pathes in tomcat. The tomcat is running behind an apache and I use the apache to proxy path the requests to tomcat. In apache I want to access both application via a hostname instead of a context path.

Scenario:

tomcat

https://domain:8443/app1
https://domain:8443/app2

in tomcat the applications have the context path app1 and app2

in apache I want to enable both application as follow:

https://app1.host/
https://app2.host/

In apache I have created a configuration for each domain:

ProxyPass /  https://localhost:8443/app1
ProxyPassReverse / https://localhost:/8443/app1

The strange thing is app1 is only available through apache using the context path:

https://app1.host/app1

Is it possible to realize such a setup with apache ProxyPass module?

Thx for your help.

A: 

You should be able to achieve the result you want by using virtual hosting. Also it's a good idea to pass the requests to tomcat via the AJP protocol instead of HTTPS. Try adding this to the Apache configuration

NameVirtualHost *:443

<VirtualHost *:443>
    ServerName app1.host
    ProxyPass / ajp://localhost:8009/app1/
</VirtualHost>

<VirtualHost *:443>
    ServerName app2.host
    ProxyPass / ajp://localhost:8009/app2/
</VirtualHost>

If you haven't changed the default server settings for Tomcat this should work just as it is. Otherwise make sure to specify the AJP port that is configured in Tomcat's conf/server.xml file. There should be a line similar to this:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Make sure that you have the mod_proxy and mod_proxy_ajp modules loaded in Apache configuration, this may vary depending on your Apache installation. Also remove any previously configured 'ProxyPass / ...' lines as they will interfere with the new configuration. Hope this works for you.

Andrius