完整Tomcat配置文件,一个服务器架设两个域名

原创 2013年12月04日 13:32:25

主要配置Host节点。

说明:

配置了主域名,xxxxx.com,www.xxxxx.com,以及二级域名或其它的域名,如:app.xxxxx.com,或www.yyyyy.net。


<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8005" shutdown="SHUTDOWN">
  <!-- Security listener. Documentation at /docs/config/listeners.html
  <Listener className="org.apache.catalina.security.SecurityListener" />
  -->
  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container",
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
        maxThreads="150" minSpareThreads="4"/>
    -->


    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080" protocol="HTTP/1.1"
               URIEncoding="ISO-8859-1"  
               connectionTimeout="20000"
               redirectPort="8443"/>

	<Connector port="80" protocol="HTTP/1.1"
			   URIEncoding="ISO-8859-1"  
			   connectionTimeout="20000"
			   redirectPort="8443"/>
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />
    -->
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"  URIEncoding="ISO-8859-1" />


    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->

    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
    -->
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      
	
      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        
	  <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log." suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />
      </Host>


	<Host name="domainname.com" debug="0" appBase="D:\opt\www" unpackWARs="true" autoDeploy="true">  
        <alias>domainname.com</alias>  
        <alias>www.domainname.com</alias>  
        <Context path="" docBase="D:\opt\www" debug="0" reloadable="true"/>  
    </Host>  
  
    <Host name="app.domainname.com" debug="0" appBase="D:\opt\app" unpackWARs="true" autoDeploy="true">  
        <alias>app.domainname.com</alias>  
        <Context path="" docBase="D:\opt\app" debug="0" reloadable="true"/>  
    </Host>  
  
        <Host name="yyyyy.net" debug="0" appBase="D:\opt\yynet" unpackWARs="true" autoDeploy="true">  
        <alias>www.yyyyy.net</alias>  
        <Context path="" docBase="D:\opt\yynet" debug="0" reloadable="true"/>  
    </Host>  

    </Engine>
  </Service>
</Server>


Tomcat多个域名指向同一个项目

有时候我们需要将多个域名指向同一个项目,那么在tomcat服务器下该如何实现呢? 之前查过有人说在 tomcat安装目录/conf/server.xml 中的server.xml配置文件中配置多个来实...
  • u013076997
  • u013076997
  • 2017年01月10日 17:43
  • 1452

网站搭建从零开始(三)域名解析

前面介绍了网站搭建所需要的两大要素:域名和服务器,这次要说的是域名解析,也就是把域名和服务器进行绑定的过程。 我们在访问网络时,网址会被发送到DNS服务器,然后由DNS服务器返回我们所要访问的服务器...
  • jzj1993
  • jzj1993
  • 2014年10月18日 01:40
  • 1664

tomcat下部署多个项目,通过域名解析到不同网站

tomcat下部署多个项目,通过域名解析到不同网站
  • u011518709
  • u011518709
  • 2014年04月17日 17:31
  • 1973

Linux+Nginx+Tomcat 多域名,多应用在同一服务器的配置

Linux+Nginx+Tomcat 多域名,多应用在同一服务器的整合配置 实现的效果和达到的目的为: 1、有两个域名www.aaa.com www.bbb.com 分别对应两个两个不同的网站,但是...
  • spokenInChina
  • spokenInChina
  • 2015年07月06日 20:34
  • 2929

tomcat 实现多域名指定同一项目

有时候我们需要将多个域名指向同一个项目,那么在tomcat服务器下该如何实现呢? 之前查过有人说用多个进行配置来实现这个功能~过程如下: ...
  • u014253480
  • u014253480
  • 2016年02月17日 21:44
  • 5619

【097】Nginx实现一台服务器,两个域名发布不同的前端项目,并且两个域名都用80端口。

有时候你可能需要在一个服务器上,用 nginx 发布两个前端项目。并且这两个前端项目使用不同的域名,域名都绑定80端口。本文说明此场景下的操作过程。Nginx使用的是 Docker 官方镜像。假设 y...
  • zhangchao19890805
  • zhangchao19890805
  • 2017年11月20日 14:58
  • 167

阿里云服务器之Tomcat环境搭建以及域名绑定

上一步主要主要讲解在服务器中建立自己的hexo博客环境,最后达到可以远程访问,以及远程git推送到github。这章主要讲解Tomcat环境的搭建,以及域名解析。...
  • peace1213
  • peace1213
  • 2015年11月28日 15:16
  • 6202

linux系统一个tomcat配置两个域名,每个域名对应一个项目

由于项目的需要,我们公司有两个域名,每个域名对应一个项目,这样我们就可以使用不同的域名访问不同的项目了, 我们的网站使用的是web服务器Tomcat,框架是自己封装的简易版jsp-servlet,域...
  • u011159417
  • u011159417
  • 2017年03月13日 12:03
  • 1677

在Linux服务器上配置多个Tomcat服务

应公司需求,现在需要把正在运行的项目和开发项目所在的服务器分开,所以需要在一个linux系统中,搭建两个tomcat应用服务器,下面总结了一下在linux系统上搭建jdk和多个tomcat服务器的步骤...
  • u011936251
  • u011936251
  • 2017年01月10日 18:09
  • 1544

在一台服务器上配置多个Tomcat的方法

这段时间在开发智能导航的热部署功能,需要从一台服务器去访问其它的24台服务器去进行相关配置的热部署。如果要在一台服务器上配置多个Tomcat,主要就是要避免Tomcat服务器的端口冲突的问题。只需要修...
  • lmb55
  • lmb55
  • 2015年11月01日 20:40
  • 5447
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:完整Tomcat配置文件,一个服务器架设两个域名
举报原因:
原因补充:

(最多只允许输入30个字)