Apache - Tomcat ProxyPass VirtualHost - Context Path

I have a problem setting the ProxyPass apache tomcat directive for two applications that have two different Context paths in tomcat. Tomcat works for apache, and I use apache for the proxy server to query tomcat. In apache, I want to access both applications via the hostname instead of the context path.

Scenario:

cat

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

in tomcat applications have context path app1 and app2

in apache I want to enable both applications as follows:

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

In apache, I created a configuration for each domain:

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

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

 https://app1.host/app1 

Is it possible to implement such a setting using the apache module ProxyPass?

Thanks for your help.

+4
source share
2 answers

You should be able to achieve the desired result using shared hosting. It is also nice to send requests to tomcat via the AJP protocol instead of HTTPS. Try adding this to your 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 have not changed the default server settings for Tomcat, this should work as it is. Otherwise, be sure to specify the AJP port that is configured in the Tomcat conf / server.xml file. There should be a line like this:

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

Make sure that the mod_proxy and mod_proxy_ajp modules are loaded into the Apache configuration, this may vary depending on the Apache installation. Also, delete all previously configured "ProxyPass / ..." lines, as they will interfere with the new configuration. Hope this works for you.

+10
source

you may try

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

with final /

+6
source

Source: https://habr.com/ru/post/1306477/


All Articles