Tomcat8設置域名或者IP訪問
阿新 • • 發佈:2019-03-15
follow ext tail csdn tomcat8 pack common example ack 環境:
Tomcat8.0.53
目標:
設置為使用指定的域名或者IP訪問
Tomcat8.0.53
目標:
設置為使用指定的域名或者IP訪問
1. 設置域名訪問
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配置域名訪問,感謝原作者的無私奉獻
Tomcat8設置域名或者IP訪問