Tomcat------如何配置域名和80端口

1.打开Tomcat的默认安装路径下的Service.xml文件

路径:C:\Program Files\Apache Software Foundation\Tomcat 8.0\conf\Server.xml

2.修改配置文件

<?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" />
  <!-- 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/TLS HTTP/1.1 Connector on port 8080
    -->  <!-- 改为80端口 -->
    <Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="2000"
               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/TLS HTTP/1.1 Connector on port 8443
         This connector uses the NIO 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.Http11NioProtocol"
               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">
    -->   <!-- 修改为域名,如:www.baidu.com -->
    <Engine name="Catalina" defaultHost="域名">

      <!--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 &quot;%r&quot; %s %b" />
      </Host>

    <!-- 新增一个Host -->
      <Host name="域名"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
      <Context path="/" docBase="C:/Program Files/Apache Software Foundation/Tomcat 8.0/webapps/网站的文件夹名称" />
      </Host>

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

3.保存,再重启Tomcat就可以了

注意:服务器IP地址得绑定域名的前提下才有效

原文地址:https://www.cnblogs.com/tianhengblogs/p/9332764.html

时间: 2024-10-03 23:00:56

Tomcat------如何配置域名和80端口的相关文章

tomcat在ubuntu14下使用80端口

此文章只说明如何打开80端口具体原理方面这里不做过多探讨. 在ubuntu10以后的版本 ubuntu 禁用了普通用户使用1-1024端口.这样当我们直接更改tomcat的server.xml 中的端口是不能正常启用80端口的.在catalina.out 里我们会发现以下错误信息. SEVERE: Failed to initialize end point associated with ProtocolHandler ["http-bio-80"] SEVERE: Failed t

一键去除域名非80端口,去掉域名后面带的端口号快速解决方案

去端口号功能主要用于Apache与IIS等WEB服务器共存时,去除域名后面所带的端口 本文案例采用我开发的纯绿色PHP集成环境PHPWAMP里面的"去端口"功能模块. 案例演示: 点击常用工具,打开"去掉域名非80端口"功能即可 弹出的界面菜单如下图 如下填写,域名填写格式abc.com,具体如下图,带红星的必填,其他为选填 只需要填写abc.com,无论是abc.com域名或者是带www的www.abc.com域名都会一键去除端口号. 信息填写完毕后,点击此处添加

如何一键去除域名非80端口,教你如何去除网址后面的端口号

如果有时候必须采用非80端口进行搭建网站,可以采用PHPWAMP内置功能"一键清除域名的非80端口" 案例采用我开发的纯绿色PHP集成环境PHPWAMP里面的"去端口"功能模块,版本号为8.1.8.8 案例演示: 点击常用工具,打开"去掉域名非80端口"功能即可 弹出的界面菜单如下图 如下填写,域名填写格式abc.com,具体如下图,带红星的必填,其他为选填 只需要填写abc.com,无论是abc.com域名或者是带www的www.abc.com

配置iptables,把80端口转到8080

在Linux的下面部署了tomcat,为了安全我们使用非root用户进行启动,但是在域名绑定时无法直接访问80端口号.众所周知,在unix下,非root用户不能监听1024以上的端口号,这个tomcat服务器就没办法绑定在80端口下.所以这里需要使用linux的端口转发机制,把到80端口的服务请求都转到8080端口上. 在root账户下面运行一下命令: iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 80

(7) 将tomcat HTTP连接器启动在80端口(jsvc使用详解)

让tomcat在80端口上运行 法一: 修改连接器的端口8080为80 <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> 然后以root身份重启tomcat即可 法二: 不修改连接器的端口,而是使用iptables转发端口流量,即将80/tcp端口的流量全部转发到8080/tcp t

centos 7 配置iptables开放80端口

centos7默认的是用firewalld进行管理防火墙的. 在安装完centos7后,安装了nginx服务器,但是同在一个局域网却访问不到,哥哥告诉我应该是防火墙开了.将防火墙关了就可以了. 果断一试. 但是每次防火墙总是自起动. 然后哥哥告诉我两种选择,要么继续用firewalld进行管理,要么用iptables. 在之前用的都是iptables,升级到7后,将firewalld换成了iptables. 在网上搜到的都是将firewall替换成iptables,就想着自己也用用iptable

CentOS7 配置防火墙开放80端口

firewall-cmd --zone=public --add-port=80/tcp  --permanent 参数详解: --zone   作用域 --add-port=80/tcp   添加端口, 格式为:  端口/ 通讯协议 --permanent     永久生效,没有此参数,重启失效

Tomcat JMX配置后,JMX端口就是不监听

百度出来的把Tomcat打开JVM的资料好多都没有提及要保证hostname -i不能是127.0.0.1这一点.弄得个人折腾了好久好久才知道原因.特记录于此,免得还有其他同事遇到像我一样的问题. 切记!  Tomcat服务器的hostname -i 返回的地址中不能有127.0.0.1这个.其他的就是按官方的文档,修改catlina.sh中的参数就可以了.

Tomcat 笔记-配置域名

编辑/etc/hosts文件,添加域名: 127.0.0.1 localhost 127.0.1.1 ubuntu # The following lines are desirable for IPv6 capable hosts ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters