Tomcat 一个端口只用于一个WAR

发布于 2024-12-26 02:01:29 字数 127 浏览 5 评论 0原文

我的 tomcat 6 服务器上运行着两个 WAR 文件。

如何设置每个 WAR 仅监听一个端口? 例如:

端口443 =>只能访问a.war

端口8000 =>只能访问b.war

I have two WAR file running in my tomcat 6 server.

How can i set each WAR listen to only one port?
For example:

port 443 => only can access a.war

port 8000 => only can access b.war

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

春花秋月 2025-01-02 02:01:29

我设法使用以下设置配置上述场景:我在 webapp 文件夹下创建了两个名为 4438000 的文件夹,并配置了两个服务-元素指向两个不同的文件夹并侦听两个不同的端口。

服务器.xml

<Service name="Catalina">
<Connector port="8000" protocol="HTTP/1.1" SSLEnabled="true"
           maxThreads="150" scheme="https" secure="true"
           keystoreFile="${catalina.base}/conf/.keystore" keystorePass="xxxxx"
           clientAuth="false" sslProtocol="TLS" />

<Engine name="Catalina" defaultHost="localhost">
  <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
         resourceName="UserDatabase"/>

  <Host name="localhost"  appBase="webapps/8000"
         unpackWARs="true" autoDeploy="true"
         xmlValidation="false" xmlNamespaceAware="false">
            <Context path="" docBase="Apple"/>
  </Host>
</Engine></Service>

<Service name="Catalina2">
<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="443" />

<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
           maxThreads="150" scheme="https" secure="true"
           keystoreFile="${catalina.base}/conf/.keystore" keystorePass="xxxxx"
           clientAuth="false" sslProtocol="TLS" />

<Engine name="Catalina2" defaultHost="localhost">
  <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
         resourceName="UserDatabase"/>

  <Host name="localhost"  appBase="webapps/443"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">
  </Host>
</Engine></Service>

I managed to configure the above scenario using these settings: I created two folders named 443 and 8000 under the webapp folder, and configured two Service-elements pointing to two different folders and listening on two different ports.

server.xml

<Service name="Catalina">
<Connector port="8000" protocol="HTTP/1.1" SSLEnabled="true"
           maxThreads="150" scheme="https" secure="true"
           keystoreFile="${catalina.base}/conf/.keystore" keystorePass="xxxxx"
           clientAuth="false" sslProtocol="TLS" />

<Engine name="Catalina" defaultHost="localhost">
  <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
         resourceName="UserDatabase"/>

  <Host name="localhost"  appBase="webapps/8000"
         unpackWARs="true" autoDeploy="true"
         xmlValidation="false" xmlNamespaceAware="false">
            <Context path="" docBase="Apple"/>
  </Host>
</Engine></Service>

<Service name="Catalina2">
<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="443" />

<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
           maxThreads="150" scheme="https" secure="true"
           keystoreFile="${catalina.base}/conf/.keystore" keystorePass="xxxxx"
           clientAuth="false" sslProtocol="TLS" />

<Engine name="Catalina2" defaultHost="localhost">
  <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
         resourceName="UserDatabase"/>

  <Host name="localhost"  appBase="webapps/443"
        unpackWARs="true" autoDeploy="true"
        xmlValidation="false" xmlNamespaceAware="false">
  </Host>
</Engine></Service>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文