简体   繁体   English

如何在侦听单个端口的单个Tomcat实例上使用不同的端口?

[英]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实例,如何在不同的主机名端口号下托管多个网站?

Example: 例:

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 )都能正常工作?

Request 1: 要求1:

GET /index.html HTTP/1.1
Host: www.sample.com

Request 2: 要求2:

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.

相关问题 如何在不同端口后面的单个 Tomcat 实例上运行不同的应用程序? - How to run different apps on single Tomcat instance behind different ports? 如何配置tomcat在单个应用程序中为不同的端点使用不同的端口? - How to configure tomcat to use different ports for different endpoints in a single application? 单个Tomcat实例和多个端口中的WAR - WAR in single Tomcat instance and multiple ports 如何在不同端口后面的单个JBoss AS 6实例上运行不同的应用程序? - How to run different apps on single JBoss AS 6 instance behind different ports? 如何在tomcat中部署将在不同端口上运行的多个Web应用程序? - How to deploy multiple web application in tomcat which will run on different ports? 在单个端口上运行两个tomcat - Running two tomcat on a single port 在单个服务器上运行2个tomcat实例 - Running 2 instance of tomcat on a single server AWS单实例Tomcat SSL - AWS Single Instance Tomcat SSL 如何使用nginx后面的多个域的单个tomcat实例用于i18n - How to use single tomcat instance with multiple domains behind nginx for i18n 如何在端口80绑定的单台计算机上安装tomcat的多个版本? - how to install multiple version of tomcat on single machine binded in port 80?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM