Apache 反向代理與 Wildfly?

Apache 反向代理與 Wildfly?

我在 Ubuntu 14.04 系統上安裝了 Apache 和 Wildfly。現在我想讓 Wildfly (本地http://localhost:8080)可以從 Apache ( http://webserver/wildfly) 存取。我該怎麼做呢?

到目前為止,我已經啟用了兩個 mod:proxyproxy_http。我在文件末尾添加了/etc/apache2/apache2.conf

ProxyRequests off
ProxyPass /wildfly/ http://localhost:8080/
ProxyPassReverse /wildfly/ http://localhost:8080/

編輯:

現在一半可以工作了,但是路徑沒有正確轉換。我在 Wildfly 上運行的應用程式之一的路徑是:

http://webserver/wildfly/testproj/Index.xhtml

但其頁面上的所有連結都是這樣處理的:

http://webserver/testproj/Page1.xhtml
http://webserver/testproj/Page2.xhtml
http://webserver/testproj/Page3.xhtml

而不是這個:

http://webserver/wildfly/testproj/Page1.xhtml
http://webserver/wildfly/testproj/Page2.xhtml
http://webserver/wildfly/testproj/Page3.xhtml

如果我在本地運行 Wildfly,一切正常。這讓我相信 Apache 反向代理配置中一定有錯誤。是對的嗎?我必須做什麼才能讓 Apache 解析正確的位址/連結?

答案1

我希望您能解決您的問題,但如果有人需要這個問題的答案,這裡是解決方案,

對於部署在 EAR 檔案外部的 Web 應用程式(WAR 部署)

在 web-inf 資料夾中

MyApp/src/main/webapp/WEB-INF/

添加包含此內容的 jboss-web.xml 文件,其中 / 是根部署,如果您想將其部署為您的案例的根,只需更改“/”和“testproj”即可。

<jboss-web>
      <context-root>/</context-root>
</jboss-web>

EAR文件

從官方文件(請查看參考資料)可以發現,在EAR文件內部,上下文根是在application.xml文件中定義的。在以下範例中,web-client.war 的上下文根是bank,因此應用程式設定為/bank,這表示URL 將為www.domaine.com/bank

 <module>
    <ejb>bank-ejb.jar</ejb>
</module>
<module>
    <web>
        <web-uri>web-client.war</web-uri>
        <context-root>bank</context-root>
    </web>
</module>

參考 : Jboss Doc - 第 6 章. 設定 Web 應用程式的上下文根

相關內容