环境: Tomcat8.0.53 目标: 设置为使用指定的域名或者IP访问
1. 设置IP访问
1.1 找到以下信息
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
1.2 修改 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>
2. 设置域名访问
2.1 找到以下信息
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
2.2 修改 name="localhost" 中的 "localhost" 为指定的域名,这里需要指定一个别名,可以保证带www和不带www都能正常访问,修改内容如下:
<Host name="" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Alias></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>