我试图在我们的unix机器上进行Tomcat服务器(远程访问),这将用于测试项目。
我使用Tomcat 5.0.25
(因为我们的作品使用相同的版本)。
现在我不想通过Apache运行它而只是想直接访问tomcat。
所以我已经部署了Tomcat并配置了server.xml(见下文),但是当我启动它时,我无法使用此URL看到tomcat 5欢迎页面:global.int.com:9082
<?xml version='1.0' encoding='utf-8'?>
<Server port="9007" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.mbeans.ServerLifecycleListener"
debug="0"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"
debug="0"/>
<!-- Global JNDI resources -->
<GlobalNamingResources>
<!-- Test entry for demonstration purposes -->
<Environment name="simpleValue" type="java.lang.Integer" value="30"/>
<!-- Editable user database that can also be used by
UserDatabaseRealm to authenticate users -->
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved">
</Resource>
<ResourceParams name="UserDatabase">
<parameter>
<name>factory</name>
<value>org.apache.catalina.users.MemoryUserDatabaseFactory</value>
</parameter>
<parameter>
<name>pathname</name>
<value>conf/tomcat-users.xml</value>
</parameter>
</ResourceParams>
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="9082" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="9020" protocol="AJP/1.3" redirectPort="9444" />
<!-- An Engine represents the entry point (within Catalina) that processes
every request. The Engine implementation for Tomcat stand alone
analyzes the HTTP headers included with the request, and passes them
on to the appropriate Host (virtual host).
Documentation at /docs/config/engine.html -->
<!-- You should set jvmRoute to support load-balancing via AJP ie :
<Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
-->
<Engine name="Catalina" defaultHost="localhost">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
<!-- Define the default virtual host
Note: XML Schema validation will not work with Xerces 2.2.
-->
<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
</Host>
</Engine>
</Service>
</Server>
我可以看到Tomcat正在运行Catalina.out说:
Jan 27, 2012 8:21:56 PM org.apache.coyote.http11.Http11Protocol start
INFO: Starting Coyote HTTP/1.1 on http-9082
Jan 27, 2012 8:21:56 PM org.apache.jk.common.ChannelSocket init
INFO: JK2: ajp13 listening on /0.0.0.0:9020
Jan 27, 2012 8:21:56 PM org.apache.jk.server.JkMain start
INFO: Jk running ID=0 time=1/14 config=/home/tomcat/tomcat5_fcl_uat/conf/jk2.properties
Jan 27, 2012 8:21:56 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2173 ms
并且命令lsof -i TCP
显示:
java 29923 tomcat 5u IPv6 373023 TCP *:9082 (LISTEN)
我无法弄清楚为什么我无法看到tomcat页面。我有另一个在端口9081上运行的Tomcat服务器,我们可以使用url global.int.com:9081
来访问它,上面的server.xml是除了端口号被更改之外的副本。任何人都可以给我一个暗示事情正在崩溃的地方。谢谢
来自远程桌面的wget -S
的结果:
--2012-01-30 17:35:42-- http://global.int.com:9082/
Resolving global.int.com... 10.215.222.78
Connecting to global.int.com|10.215.222.78|:9082... failed: No route
to host.
以下是 LocalHost计算机上wget -S
的结果:
[tomcat@global logs]$ wget -S http://global.int.com:9082/
--16:17:03-- http://global.int.com:9082/
Resolving global.int.com:9082... 10.213.210.78
Connecting to global.int.com:9082|10.213.210.78|:9082... connected.
HTTP request sent, awaiting response...
HTTP/1.1 200 OK
Content-Type: text/html;charset=ISO-8859-1
Date: Sat, 28 Jan 2012 05:17:03 GMT
Server: Apache-Coyote/1.1
Connection: close
Length: unspecified [text/html]
Saving to: `index.html'
[ <=> ] 9,312 --.-K/s in 0s
16:17:03 (297 MB/s) - `index.html' saved [9312]
[tomcat@global logs]$
iptables -L -v -n
: 106 5920 ACCEPT tcp -- * * 10.0.0.0/8 0.0.0.0/0 tcp dpt:8080
6 312 ACCEPT tcp -- * * 10.0.0.0/8 0.0.0.0/0 tcp dpt:8180
0 0 ACCEPT tcp -- * * 10.0.0.0/8 0.0.0.0/0 tcp dpt:9080
19 988 ACCEPT tcp -- * * 10.0.0.0/8 0.0.0.0/0 tcp dpt:9081
如果我错了,请纠正我 - 但上面的结果显示了我无法访问tomcat的原因,因为我已将端口9082分配给tomcat,并且上述列表中不存在该端口。
server.xml
中使用的所有端口号都是唯一的(我已经双重检查)。有关为什么我无法看到Tomcat主页以及如何解决它的任何建议?
答案 0 :(得分:1)
原来这是一个阻止传入连接的防火墙问题。 iptables -L -v -n
(在Linux上)帮助揭示了实际问题。有关详细信息,请参阅该文章下的评论。