简体   繁体   中英

referring to tomcat URLs via multiple aliases in an apache web server + tomcat setup

I have an apache web server that acts as a load balancer / gateway for the base url, say http://example.com

In turn, there is routing logic within the apache web server to forward the requests to individual tomcat servers eg app1, app2 via the paths http://example.com/app1 , http://example.com/app2 .

Here, app1 and app2 are separate tomcat instances and they are separate webapps.

Now there is a need to refer to http://example.com/app1 also as http://example.com/alias1 , ie both /app1 and /alias1 must route to the tomcat server corresponding to app1, with only one app1 installed (ie alias1 is not a separate tomcat instance)

Any pointers to documentation for setting up an alias for a tomcat webapp in this fashion would be appreciated.

You can use apahce ReverseProxy technology to "route" request to different tomcats depending on the url: https://httpd.apache.org/docs/current/mod/mod_proxy.html

You can start with something like this:

ProxyPass "/foo/" "http://foo.tamcat.lan:8080/foo/"
ProxyPassReverse "/foo/" "http://foo.tomcat.lan:8080/foo/"

ProxyPass "/bar/" "http://192.168.254.30:8080/"
ProxyPassReverse "/bar/" "http://192.168.254.30:8080/"

and if it's working, you can add a rule (which can be another proxyPass, a rewriteRule with proxy flag or whatever you need/like) for the alias.

Even tho it's not an optimal solution, if you have multiple tomcat servin the same application, you can also load balance the traffic: https://httpd.apache.org/docs/2.4/howto/reverse_proxy.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM