Tomcat 和多个域/应用程序 [英] Tomcat and multiple domains/applications

查看:34
本文介绍了Tomcat 和多个域/应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我在端口 80 上运行带有单个 WAR 应用程序的单个 tomcat.域名 www.foo.org 指向此服务器 ip.

Currently I run single tomcat with single WAR application on port 80. The domain name www.foo.org is pointed to this server ip.

在端口 80 上为不同的客户端添加 www.bar.org 域的过程是什么?

What is the procedure of adding www.bar.org domain for a different client on port 80?

谢谢

推荐答案

从一开始,您的 conf/server.xml 中就有一个用于 localhost

From the beginning you have a single "Host" record in your conf/server.xml for localhost

<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">
      <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</Host>

现在您可以添加另一个主机"记录,例如

Now you can add another "Host" records, for example

  <Host name="anotherclient.com"  appBase="anotherclient" unpackWARs="true" autoDeploy="true">

       <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="anotherclient_access_log." suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />
  </Host>

其中 name="anotherclient.com" 是新客户端的域,而 appBase="anotherclient" 是它的 Web 应用程序根目录名称(您在其中部署战争);它是相对于 tomcat 主目录的.

where name="anotherclient.com" is the new client's domain, and appBase="anotherclient" is its web application root directory name (where you deploy your war); it is relative to the tomcat home dir.

tomcat 重启后会接受更改.

Changes will be accepted after tomcat is restarted.

发送到任何其他域(未在 server.xml 中列出)但指向您服务器的 IP 地址的请求将被传递到默认应用程序,它在 Engine<中指定/code> 元素

Requests going to any other domains (not listed in server.xml) but pointing to IP address of your server will be passed to the default application, it is specified in the Engine element

<Engine name="Catalina" defaultHost="localhost">

这篇关于Tomcat 和多个域/应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆