Tomcat實現多IP域名,多埠訪問
阿新 • • 發佈:2019-01-02
多埠訪問:
原理就是設定多個埠監聽
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
<Connector port="8088" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
多域名訪問:
1訪問同一個web專案
通過nginx的IP反向代理對映到對應tomcat域名可以實現過IP訪問同一個專案<Host name="domain1" appBase="webapps" unpackWARs="true" autoDeploy="true"> ..... </Host> <Host name="domain2" appBase="webapps" unpackWARs="true" autoDeploy="true"> ..... </Host>
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>