tomcat绑定域名后让外网访问的方法:
1.打开需要修改的apache-tomcat-7.0.92\conf\server.xml配置文件。
2.将protocol属性值为HTTP/1.1的Connector元素的port属性值改为80。
<!-- ... --><Service name="Catalina">
<!-- ... -->
<!-- 将这里的8080改为80 -->
<Connector port="8080" protocol="HTTP/1.1"
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 :<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<!-- 将这里的defaultHost的值改为服务器的公网IP,或域名 -->
<Engine name="Catalina" defaultHost="localhost">
<!--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或域名 --><Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<!-- 添加Context元素,并将docBase设置为项目地址 -->
<Context path="" docBase="C:\Program Files\apache-tomcat-7.0.92\webapps\Project"/>
<!-- 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>
5.最后重启tomcat即可。