
tomcat绑定域名后让外网访问的方法:
1.打开需要修改的apache-tomcat-7.0.92\conf\server.xml配置文件。
2.将protocol属性值为HTTP/1.1的Connector元素的port属性值改为80。
<!-- ... -->
<!-- ... -->
<!-- 将这里的8080改为80 -->
connectionTimeout="20000"
redirectPort="8443" />
<!-- A "Connector" using the shared thread pool-->
<!-- ... -->
3.再将Engine元素的defaultHost值改为服务器公网IP或域名。
<!-- You should set jvmRoute to support load-balancing via AJP ie :
-->
<!-- 将这里的defaultHost的值改为服务器的公网IP,或域名 -->
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
4.在Host元素中将name属性值localhost改为服务器的公网IP或域名。
<!-- 将这里的localhost改为公网ip或域名 -->
unpackWARs="true" autoDeploy="true">
<!-- 添加Context元素,并将docBase设置为项目地址 -->
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
ssLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
5.最后重启tomcat即可。