简体   繁体   中英

Multiple domains (Apache web server) with mutiple tomcat apps (tomcat 9) with single IP

This the configuration of my server. I have domain1(domain1.com) and domain2(domain2.com), Domain3 (domain3.com) Domain1.com hosts tomcatapp1, tomcatapp2 Domain2.com hosts tomcatapp1, tomcatapp2, tomcatapp3. Domain2.com hosts tomcatapp4, tomcatapp5, tomcatapp6, tomcatapp1.

This could also include subdomains. Subdomain1.Domain1.com (tomcatapp4, tomcatapp5, tomcatapp6, tomcatapp1)

All the domains are on single IP with the port 80 for Apache and 8080 for tomcat. Question is how do I achieve this ?

I started with VirtualHosts on Apache where each domain is pointing to a directory (in this case it is Domain1.com, Domain2.com). But I got stuck when I wanted to introduce the multiple apps in each of the domains.

Appreciate if somebody could suggest or point to a proper documentation discussing this aspect.

It is not possible to have multiple sockets bound to the same IP address, listening on the same port (8080 in your example). This is not a limitation of TomCat or Apache, but a feature of IP networking in general.

You have a few options:

  1. set up each TomCat application with a different port and route your Apache virtual hosts for each subdomain to one of the ports

  2. provision multiple IP addresses on the box and have each TomCat app listen on the same port but be bound to only one distinct IP address each

  3. run the apps on different physical hosts (again each having it's own IP address)

All three basically boil down to the same concept: you bind each of the server applications to listen on a distinct port and you route requests from a proxy (Apache in your case) to each server based on the hostname, mapping port 80 externally to a local port (say 8081, 8082, 8083, etc.)

The easiest to configure is Option #1

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