我在使用 Tomcat 时遇到了问题:
在全新安装中,连接 [ip-address]:8080 超时。
我见过很多类似的问题,基本上尝试了所有方法,但都没有成功。但这是我与类似问题相关的所有数据:
版本:Tomcat 7
Linux:Ubuntu
iptables -L 输出:
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
netstat -nat | grep :8080 输出
tcp6 0 0 :::8080 :::* LISTEN
telnet localhost 8080 输出
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
telnet [ip 地址] 8080 输出
Trying [ip-address]... (this seems to go on forever)
我感觉我肯定忽略了一些非常明显的东西,因为除了安装 java 和 tomcat 之外,我没有添加任何 WAR/对服务器进行任何修改。以下是我的 Server.xml(注释已删除):
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.core.JasperListener" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="8443" address="0.0.0.0" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" />
</Host>
</Engine>
</Service>
</Server>
答案1
由于您使用的是 Amazon EC2,并且它在实例本地工作,而不是在其 IP 地址上工作,请检查主机的网络 ACL(即安全组)。向导会指导您设置一个非常严格的策略,如果您尝试执行诸如向世界开放 HTTP 之类的操作,它只会打开入站端口 80。