Tomcat 6只有localhost返回200,从另一个盒子通过IP连接但返回403?

时间:2012-03-27 17:14:45

标签: tomcat ubuntu tomcat6

我正在尝试设置黑莓推送服务器,该服务器在tomcat 6中运行。此安装程序执行正常,一切正常并按预期运行。

但是,我只能从本地机器连接到它,我可以使用链接或wget从盒子中证明。因此,localhost:8080按预期返回默认的Tomcat页面,并且Web管理器等正常运行。

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

  

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

这已被记录。

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

  1. <Alias>ipaddresshere</Alias>到server.xml,位于locathost <Host>
  2. 尝试更改<Host>部分的名称属性。
  3. 添加名称为IP地址的单独<Host>部分
  4. 我在每次更改后运行shutdown.sh然后运行startup.sh,这些都是干净的。

    这是我的server.xml

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

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

    除非适用法律要求或书面同意,否则软件   根据许可证分发的“按现状”分发,   不附带任何明示或暗示的保证或条件。   有关管理权限的特定语言,请参阅许可证   许可证下的限制。 - &GT;

                           

                   

      

    <!--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>
    

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

    任何人都可以在这里看到我在这里出错,再次我确信它是一个tomcat配置的东西。我通过apt运行Ubuntu 10.04 LTS以及所有最新更新。

1 个答案:

答案 0 :(得分:0)

一旦我在这里问过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>

诀窍。