Tomcat6只有localhost返回200,通过IP连接从另一个盒子返回403



我正在尝试设置运行在tomcat 6中的blackberry推送服务器。安装程序执行得很好,一切都按预期运行。

然而,我只能从本地机器连接到它,我可以使用盒子里的链接或wget来证明这一点。因此,localhost:8080按预期返回默认Tomcat页面,web管理器等运行良好。

一旦我尝试通过ip连接到这个,例如,http://ipaddress:8080它连接到Tomcat,但返回403,显示-

description已禁止访问指定的资源()。

这已经被记录下来了。

因此,看起来这不是网络问题,而是Tomcat配置问题。我一直在阅读这些文档,感觉自己忽略了一些愚蠢而简单的东西。我试过

  1. <Alias>ipaddresshere</Alias>到server.xml,位于locatehost <Host>
  2. 已尝试更改<Host>节的名称属性
  3. 添加一个单独的<Host>节,名称为IP地址

我正在运行shutdown.sh,然后在每次更改后启动.sh,这些都会清理干净。

这是我的server.xml

<?xml version='1.0' encoding='utf-8'?>

  http://www.apache.org/licenses/LICENSE-2.0

除非适用法律要求或书面同意,软件根据许可证进行的分发是在"按原样"的基础上进行的,无任何明示或暗示的保证或条件。有关管理权限的特定语言,请参阅许可证许可下的限制。-->

<!--The connectors can use a shared executor, you can define one or more named thread pools-->
<!--
<Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
    maxThreads="150" minSpareThreads="4"/>
-->

<!-- A "Connector" represents an endpoint by which requests are received
     and responses are returned. Documentation at :
     Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
     Java AJP  Connector: /docs/config/ajp.html
     APR (HTTP/AJP) Connector: /docs/apr.html
     Define a non-SSL HTTP/1.1 Connector on port 8080
-->
<Connector port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" useBodyEncodingForURI="true" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
           port="8080" protocol="HTTP/1.1" 
           connectionTimeout="20000" 
           redirectPort="8443" />
-->           
<!-- Define a SSL HTTP/1.1 Connector on port 8443
     This connector uses the JSSE configuration, when using APR, the 
     connector should be using the OpenSSL style configuration
     described in the APR documentation -->
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
           maxThreads="150" scheme="https" secure="true" 
           keystoreFile="keystores/.keystore" keystorePass="changeit" 
       clientAuth="false" sslProtocol="TLS" useBodyEncodingForURI="true"/>

<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

<!-- 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">
  <!--For clustering, please take a look at documentation at:
      /docs/cluster-howto.html  (simple how to)
      /docs/config/cluster.html (reference documentation) -->
  <!--
  <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
  -->        
  <!-- The request dumper valve dumps useful debugging information about
       the request and response data received and sent by Tomcat.
       Documentation at: /docs/config/valve.html -->
  <!--
  <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
  -->
  <!-- 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">
<Alias>IPADDRESSHERE</Alias>
<Alias>CL-Blackberry</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 -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
           prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="true"  />
  </Host>
</Engine>

此服务器仅供内部网络使用。

有人能发现我这里出了问题吗?我再次确信这是一个假小子的配置。我通过apt.

运行Ubuntu 10.04 LTS和所有最新更新

一旦我在SO上问过这里,我似乎总能找到解决方案!

无论如何,这是添加第二个<Host>和localhost的情况。这第一次不起作用,我不知道为什么,也许Tomcat在这次更改后没有恢复正常。

因此,在localhost:下面添加以下内容

<Host name="10.100.9.170" appBase="webapps" unpackWARs="true" autodeploy="true" xmlValidation="false" >
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"  
           prefix="10-100-9-170_access_log." suffix=".txt" pattern="common" resolveHosts="true"  />
  </Host>

成功了。

最新更新