标签:color top .com comm href val pac example dir
环境:1.1 打开Tomcat下conf目录的server.xml文件,找到以下信息

修改 Engine
engine指定缺省的处理请求的主机名,它至少与其中的一个host元素的name属性值是一样的
<Engine name="Catalina" defaultHost="www.678910.top">
1.2 再找到以下信息
<Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">

1.2.1 修改 name="localhost" 中的 "localhost" 为指定的IP
<Host name="63.99.68.186"  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>

1.2.2 修改 name="localhost" 中的 "localhost" 为指定的域名,这里需要指定一个别名,可以保证带www和不带www都能正常访问
<Host name="www.678910.top"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
    <Alias>678910.top</Alias>
    <!-- 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>

参考自Tomcat8配置域名访问,感谢原作者的无私奉献
标签:color top .com comm href val pac example dir
原文地址:https://blog.51cto.com/1197822/2363732