Apache TomCat 僅在本機上工作 - Windows 2012

Apache TomCat 僅在本機上工作 - Windows 2012

我已經在windows server 2012上安裝了Apache Tomcat並且可以在本地存取它

到目前為止,我已嘗試以下操作: - 透過防火牆開啟連接埠 - 透過我的雲端伺服器主機開啟連接埠。 - 關閉 Windows 防火牆 - 對 server.xml 檔案進行更改 - 聯絡我的雲端伺服器主機,他已確認連接埠 90 正在運作。 - 我的主機提供者已經嘗試過,但他們也無法讓它運作。

我已停止並重新啟動該服務,但沒有任何效果:

下面是我的 server.xml 文件,當我嘗試存取時,日誌似乎不包含任何錯誤。

  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="9090" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443"
     address="0.0.0.0" />
<!-- A "Connector" using the shared thread pool-->
<!--
<Connector executor="tomcatThreadPool"
           port="9090" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443"
    address="0.0.0.0" />
-->
<!-- 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"
           clientAuth="false" sslProtocol="TLS" />
-->

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

  <!-- Use the LockOutRealm to prevent attempts to guess user passwords
       via a brute-force attack -->
  <Realm className="org.apache.catalina.realm.LockOutRealm">
    <!-- 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"/>
  </Realm>

  <Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true">

    <!-- 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
         Note: The pattern used is equivalent to using pattern="common" -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log." suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />

  </Host>
</Engine>

請提供任何幫助,因為我現在似乎正在轉來轉去。

預先感謝約翰

答案1

這在Linux下對我有用。您可以在 Windows 中嘗試此修復以遠端存取 tomcat。

在文字編輯器中開啟以下兩個 XML 檔案並註解掉以下行:

1)$CATALINA_HOME/webapps/manager/META-INF/context.xml

2) $CATALINA_HOME/webapps/host-manager/META-INF/context.xml

註解掉:

<!--  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
      allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1" />-->

重新啟動您的 tomcat 伺服器並查看此解決方案是否有幫助。

答案2

經過幾個小時後,我的主機公司似乎沒有打開正確的防火牆端口,例如他們打開了 80 而不是 8080。

經驗教訓總是跟隨你的直覺。在放在這裡之前我問他們是否開放,但沒有。

無論如何,任何與此相關的人請三次檢查您的防火牆連接埠是否已開啟。

希望它能幫助別人。

謝謝約翰

相關內容