Redirect the url to go to the tomcat servlet using Apache / mod_proxy

I currently have a tomcat 1 servlet running under ROOT:

api1.myhost.com:8080/

I use mod_proxy and just forward all requests from api1.myhost.com to this instance. It works today.

Now I installed the second servlet 2, which runs under the same tomcat instance (same IP address):

www.myhost.com:8080/servlet2

I want all requests to the new api2 URL to go to the second servlet so that:

API2 .myhost.com

now sent to the second instance of the servlet.

I created an A record, so api2.myhost.com points to my server IP address. How do you do api2.myhost.com at www.myhost.com:8080/servlet2?

+3
1

VirtualHost webapp, .

<VirtualHost *:80>
    ServerName api1.myhost.com
    ProxyPass / http://api1.myhost.com:8080/
    ProxyPassReverse / http://api1.myhost.com:8080/
</VirtualHost>

<VirtualHost *:80>
        ServerName api2.myhost.com
        ProxyPass / http://www.myhost.com:8080/servlet2
        ProxyPassReverse / http://www.myhost.com:8080/servlet2
</VirtualHost>

, tomcat, apache, URL- .

+3

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


All Articles