`
qingyu11068
  • 浏览: 67779 次
文章分类
社区版块
存档分类
最新评论

Tomcat 配置支持不同的域名访问各自不同程序的配置方法

 
阅读更多

配置好的 server.xml  此文件在 conf文件夹下面

<?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">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <!-- 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="80" protocol="HTTP/1.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 BIO implementation that requires the JSSE
         style configuration. When using the APR/native implementation, the
         OpenSSL style configuration is required as described in the APR/native
         documentation -->
    <!--
    <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
               maxThreads="150" SSLEnabled="true" 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" />


    <!-- 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">

      <!--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="www.fhadmin.cn"  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>

		<Host name="www.1b23.com"  appBase="webapps2"
            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>

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

其中配置的关键是在

        <Host name="www.fhadmin.cn"  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>

		<Host name="www.1b23.com"  appBase="webapps2"
            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>

在tomcat 目录下面增加个文件夹 appBase="webapps"  appBase="webapps2"

webapps 下面放域名1指向的项目   webapps2 下面放域名1指向的项目 

0
1
分享到:
评论

相关推荐

    Tomcat支持不同的域名访问各自不同程序的配置方法

    本篇文章将深入探讨如何配置Tomcat以支持不同的域名访问各自独立的应用程序。 首先,理解基础配置:在Tomcat的`conf/server.xml`文件中,`Host`元素是用于定义虚拟主机的关键。每个`Host`元素代表一个域名,可以...

    Tomcat6部署一个web工程 配置SSL双域名双证书

    标题中的“Tomcat6部署一个web工程配置SSL双域名双证书”是指在Apache Tomcat 6版本中,如何为一个Web应用程序配置SSL(Secure Sockets Layer)以支持两个不同的域名并使用各自的数字证书进行安全通信。这个过程对于...

    nginx-配置多个tomcat

    现在,你可以在浏览器中访问example1.com和example2.com,应该能看到由各自Tomcat实例服务的页面。 总结来说,通过Nginx配置多个Tomcat,我们可以实现对多个Web应用程序的集中管理,提高系统的可扩展性和可用性。...

    Apache+Tomcat集群配置

    ### Apache+Tomcat集群配置详解 #### 一、技术基础 Apache和Tomcat均属于Apache...此外,根据实际应用场景的不同,还可以进一步优化配置,如增加更多的Tomcat实例来进一步分散负载,或者使用更高级的负载均衡策略等。

    tamcat绑定多个域名&配置虚拟目录

    ### Tomcat绑定多个域名及配置虚拟目录详解 在IT领域,Tomcat服务器是Java应用程序部署中不可或缺的一部分。本文将深入探讨如何在Tomcat上绑定多个域名以及如何配置虚拟目录。 #### 一、Tomcat绑定多个域名的方法 ...

    tomcat中文帮助手册

    2. **安装与配置**:介绍如何在不同的操作系统上下载、安装Tomcat,并设置环境变量。此外,还将讲解如何修改`server.xml`等配置文件,以满足特定的服务器需求。 3. **启动与停止**:详细解析如何启动和停止Tomcat...

    IIS、TOMCAT和APACHE整合

    在IT行业中,IIS(Internet Information Services)、Tomcat和Apache都是常见的Web服务器,它们各自有着不同的特性和用途。本文将详细探讨如何实现这三种服务器的整合,以及它们共用同一个端口的可能性。 首先,让...

    nginx实现Tomcat反向代理

    在IT行业中,尤其是在服务器部署和优化领域,Nginx与Tomcat的组合是常见的解决方案,因为它们各自在处理不同类型的请求上具有优势。Nginx以其高性能、低资源消耗著称,适合处理静态内容和反向代理任务;而Tomcat作为...

    Tomcat建立虚拟主机最佳实践

    在Apache Tomcat服务器中,虚拟主机(Virtual Host)是一种将多个域名或应用程序映射到同一台服务器上的技术。这使得一台服务器能够处理来自不同域名的请求,而每个域名看到的是各自独立的应用环境。在本文中,我们...

    java源码:Java应用服务器 Tomcat.zip

    2. **容器概念**:Tomcat采用容器的概念来管理Servlet,如Context、Wrapper和Loader等,这些容器各自负责不同的职责。 3. **线程模型**:Tomcat如何使用工作线程池处理请求,提高并发性能。 4. **连接器设计**:...

    tomcat中Server.xml的标签释义

    在探讨Tomcat中`Server.xml`的标签释义时,我们深入分析了构成Tomcat服务器架构的核心组件,包括Server、Service、Connector、...理解和掌握这些组件的工作原理,对于优化Tomcat的配置和提高应用程序的性能至关重要。

    常见的web服务器日志切割方法

    ### 常见Web服务器日志切割方法 ...综上所述,无论是IIS、Apache还是Tomcat,都有各自的方法来实现日志文件的有效管理和发布。合理的日志管理不仅可以提高数据安全性,还可以为后续的数据分析提供强有力的支持。

    基于springboot+uniapp微信小程序实现的学生互动课堂,采用前后端分离开发模式.zip

    UniApp是一个多端开发框架,允许开发者使用一套代码编写,同时支持H5、微信小程序、支付宝小程序等多平台。它基于Vue.js,提供了丰富的组件库和API,简化了跨平台开发。在这个互动课堂中,UniApp负责展示用户界面,...

    Openfire_spark_安装手册.pdf

    - 如果局域网内没有安装DNS服务器,则需要手动为运行Openfire的机器配置域名。这可以通过编辑`C:\WINDOWS\system32\drivers\etc\hosts`文件来实现,添加一条记录如`127.0.0.1 bzwang.tzsoft.com`。 - 对于其他需要...

    Openfire_spark安装手册.pdf

    - 对于需要访问Openfire服务器的其他机器,同样需要在它们各自的`hosts`文件中添加相应的IP地址和域名映射记录。 ##### 2.2 安装Openfire ###### 2.2.1 安装 - 下载并运行安装程序`openfire_3_6_4.exe`,在安装...

    Java开发技术大全(500个源代码).

    showMain.java 演示main方法访问本类成员 showMethod.java 演示如何定义一个方法体 showReturn_1.java return语句示例1 showReturn_2.java return语句示例2 showStaicVar.java 演示静态变量的使用 staticBlock...

Global site tag (gtag.js) - Google Analytics