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

标签 tomcat ubuntu tomcat6

我正在尝试设置在 tomcat 6 中运行的黑莓推送服务器。此安装程序执行良好,一切都按预期启动和运行。

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

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

description Access to the specified resource () has been forbidden.

这已被记录。

因此看起来这不是网络问题而是 Tomcat 配置问题。我一直在通读文档,觉得我在这里忽略了一些非常简单的事情。我试过了

  1. <Alias>ipaddresshere</Alias>到 server.xml,在 locathost 下 <Host>
  2. 尝试更改 <Host> 的名称属性部分。
  3. 添加一个单独的 <Host>名称为 IP 地址的部分

每次更改后,我都会先运行 shutdown.sh,然后运行 ​​startup.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>

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

任何人都可以在这里发现我在这里出错,我再次确信它是一个 tomcat 配置问题。我通过 apt 运行带有所有最新更新的 Ubuntu 10.04 LTS。

最佳答案

一旦我在这里提出问题,我似乎总能找到解决方案!

无论如何,这是添加第二个的情况 <Host>与本地主机一起。第一次没有成功,我不确定为什么,也许 Tomcat 在此更改后没有恢复干净。

所以,在本地主机下面添加:

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

成功了。

关于Tomcat 6 只有 localhost 返回 200,从另一个盒子通过 IP 连接但返回 403?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9894387/

相关文章:

tomcat - "javax.net.ssl.SSLHandshakeException: server certificate change is restrictedduring renegotiation"是什么意思,如何预防?

java - 如何获取文件路径?

azure - 负载均衡器 IP 和入口 IP 状态在 kubernetes 中待定

java - OpenJDK 64 位服务器虚拟机警告 :Options -Xverify:none and -noverify were deprecated in JDK 13

authentication - Tomcat - 启用双向 SSL

java - Liberty/Bluemix 上的 Spring Boot 应用程序启动 Apache,将服务器 header 附加到所有响应

maven - Maven tomcat7 :run 中 java.util.logging 处理程序的 ClassNotFoundException

bash - gnu parallel 并行化一个for循环

apache - 使用log4j为内部日志配置tomcat!

eclipse - 如何使用tomcat作为文件服务器