[英]How to use different ports on single Tomcat instance which listens on a single port?
Using a single Tomcat instance, which listens on a single port, how can I host multiple websites under different hostnames and port numbers? 使用一个在单个端口上侦听的Tomcat实例,如何在不同的主机名和端口号下托管多个网站?
Let's say that the single tomcat instance is listening on a single port: At localhost:9090
. 假设单个tomcat实例正在单个端口上侦听:在
localhost:9090
。
How can I configure Tomcat and/or my webpages in order for both of the following requests (which are sent to localhost:9090
) to work? 如何配置Tomcat和/或我的网页,以使以下两个请求(发送到
localhost:9090
)都能正常工作?
GET /index.html HTTP/1.1
Host: www.sample.com
GET /index.html HTTP/1.1
Host: www.sample.com:120
Setup different connectors in conf/server.xml (don't choose ports below 1024): 在conf / server.xml中设置其他连接器(不要选择1024以下的端口):
....
<Connector port="80" connectionTimeout="20000" protocol="HTTP/1.1" redirectPort="8443"/>
<Connector port="1234" connectionTimeout="20000" protocol="HTTP/1.1" redirectPort="8443"/>
<Engine defaultHost="localhost" name="Catalina" jvmRoute="tomcat8">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps" autoDeploy="true"unpackWARs="true"></Host>
<Host name="www.sample.com" appBase="webapps-samplecom" autoDeploy="true"unpackWARs="true"></Host>
...
</Engine>
...
This will enable www.sample.com, www.sample.com:1234. 这将启用www.sample.com,www.sample.com:1234。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.