3 回答
TA贡献1851条经验 获得超4个赞
我认为您可以在server.xml文件中进行配置,并放置2个服务:
<Service name="app1">
<Connector port="8081" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000"
redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="app1"
unpackWARs="true" autoDeploy="true">
</Host>
</Engine>
</Service>
<Service name="app2">
<Connector port="8082" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000"
redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Host name="localhost" appBase="app2"
unpackWARs="true" autoDeploy="true">
</Host>
</Engine>
</Service>
TA贡献1829条经验 获得超7个赞
除了运行两个Tomcat实例并使用ROOT应用程序(已经说过,这是一种较差且无效的解决方案)之外,您还可以使用Apache + Tomcat来实现。配置apache侦听两个端口并通过IP:Port转发到不同的Tomcat应用程序。但是您需要使用tomcat的其他端口!
Apache配置
listen 8080,8081
...
<VirtualHost *:8080>
ServerName localhost
ProxyPass / http://localhost:8888/app1
ProxyPassReverse / http://localhost:8080/app1
</VirtualHost>
<VirtualHost *:8081>
ServerName localhost
ProxyPass / http://localhost:8888/app2
ProxyPassReverse / http://localhost:8080/app2
</VirtualHost>
要么
listen 80,81
...
<VirtualHost *:80>
ServerName localhost
ProxyPass / http://localhost:8080/app1
ProxyPassReverse / http://localhost:8080/app1
</VirtualHost>
<VirtualHost *:81>
ServerName localhost
ProxyPass / http://localhost:8080/app2
ProxyPassReverse / http://localhost:8080/app2
</VirtualHost>
添加回答
举报