1. 程式人生 > >Tomcat實現多IP域名,多埠訪問

Tomcat實現多IP域名,多埠訪問

多埠訪問:

原理就是設定多個埠監聽

<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<Connector port="8088" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
多域名訪問:

1訪問同一個web專案

<Host name="domain1" appBase="webapps" unpackWARs="true" autoDeploy="true">
.....
</Host>
<Host name="domain2" appBase="webapps" unpackWARs="true" autoDeploy="true">
.....
</Host>
通過nginx的IP反向代理對映到對應tomcat域名可以實現過IP訪問同一個專案

2訪問不同web專案

<Host name="domain1" appBase="webapps" unpackWARs="true" autoDeploy="true">
	<Context path="" docBase="AbsolutelyPath/ProA"/>
</Host>
<Host name="domain2" appBase="webapps" unpackWARs="true" autoDeploy="true">
	<Context path="" docBase="AbsolutelyPath/Pro
B"/> </Host>
不同域名和埠訪問:
<Service name="Catalina1">
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<Host name="localhost" appBase="webapps1" unpackWARs="true" autoDeploy="true">
</Service>
<Service name="Catalina2">
	<Connector port="8099" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
	<Host name="localhost" appBase="webapps1" unpackWARs="true" autoDeploy="true">
</Service>