简体   繁体   English

如何在端口80绑定的单台计算机上安装tomcat的多个版本?

[英]how to install multiple version of tomcat on single machine binded in port 80?

I have three web app running on three version of tomcat like this: 我在三个版本的tomcat上运行三个Web应用程序,如下所示:

  1. app1 work on tomcat 7 and jdk 7 (app1domain.com:2121) app1在tomcat 7和jdk 7上工作(app1domain.com:2121)
  2. app2 work on tomcat 8 and jdk 8 (app2domain.com:2222) app2在tomcat 8和jdk 8上工作(app2domain.com:2222)
  3. app3 work on tomcat 9 and jdk 8 (app3domain.com:2323) app3在tomcat 9和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 有Windows Server2012。我想对上面的所有tomcat使用端口80,用户可以看到没有端口号的app1domain.com

I can install other tomcat and I want use virtual hosting for every tomcat 我可以安装其他tomcat,并且我想为每个tomcat使用虚拟主机

Is there any software or solution to do that ? 是否有任何软件或解决方案可以做到这一点?

Use nginx, easy to use and free as proxy software to manage apps and web servers. 使用易于使用且免费提供的nginx作为代理软件来管理应用程序和Web服务器。 First you can config tomcats,In tomcat server.xml 首先,您可以在tomcat server.xml中配置tomcats

<!-- 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 在Nginx中,编辑/ etc / nginx / sites-enabled / default,然后输入以下内容:/ 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. 它告诉Nginx将流量从端口80重定向到端口8080上的Apache Tomcat。完成后,重新启动Nginx。

source link 源链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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