0
votes

I have three web app running on three version of tomcat like this:

  1. app1 work on tomcat 7 and jdk 7 (app1domain.com:2121)
  2. app2 work on tomcat 8 and jdk 8 (app2domain.com:2222)
  3. app3 work on tomcat 9 and jdk 8 (app3domain.com:2323)

There is windows server 2012. I want to use port 80 for all tomcat above and user can see app1domain.com without port number

I can install other tomcat and I want use virtual hosting for every tomcat

Is there any software or solution to do that ?

1
No. You can't have several process all listeneing on the same port.You can have one tomcat, and have the 3 applications deployed on this unique server. Or leave your tomcats as is, and install a reverse proxy (nginx, apache, etc.) listening on port 80, and forwarding to one of the tomcats based on the domain. - JB Nizet
@JBNizet You can if you have 3 IP addresses, and each Tomcat will bind on its dedicated IP. - Eugène Adell
Yes you can. Setup the IIS webserver to work as a proxy to your tomcats. Configure three subdomains, each routing to one of them. - Stefan

1 Answers

0
votes

Use nginx, easy to use and free as proxy software to manage apps and web servers. First you can config tomcats,In tomcat server.xml

<!-- Tomcat listen on 8080 -->
<Connector port="8080" protocol="HTTP/1.1"
   connectionTimeout="20000"
   URIEncoding="UTF-8"
   redirectPort="8443" />
<!-- dont change the code up -->
<!-- Set /apple as default path -->
<Host name="localhost"  appBase="webapps"
     unpackWARs="true" autoDeploy="true">

 <Context path="" docBase="apple">
     <!-- Default set of monitored resources -->
     <WatchedResource>WEB-INF/web.xml</WatchedResource>
 </Context>
</Host>

In Nginx, edit /etc/nginx/sites-enabled/default, put following content : /etc/nginx/sites-enabled/default

server {
  listen          80;
  server_name     yourdomain.com;
  root            /etc/tomcat7/webapps/apple;

  proxy_cache one;

  location / {
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_pass http://127.0.0.1:8080/;
  }
}

It tells Nginx to redirect the traffics from port 80 to Apache Tomcat on port 8080. Done, restart Nginx.

source link