2015-12-02 35 views
1

我有具有結構等的EAR應用程序,端口統一在Wildfly-8.2.1

abc.ear

  • def.war
  • def1.war
  • ghi.jar

該應用程序在Wildfly服務器上運行良好,分別爲:

  1. HTTP:http://localhost:8080/HelloWorld/
  2. HTTPS:https://localhost:8443/HelloWorld/

我想重定向所有的HTTP(8080端口)請求到HTTPS(端口8443)。
任何幫助熱烈讚賞。

+0

你檢查此[鏈接](https://docs.jboss.org/jbossweb/3.0。 x/ssl-howto.html) – AntJavaDev

+0

是的,但該鏈接僅有助於保護Web應用程序。 – Navin

回答

1

如果我理解正確,你有一個webapp打包在一個EAR文件中。所以,你可以在web應用的web.xml補充一點:

<security-constraint> 
    <web-resource-collection> 
     <web-resource-name>everything</web-resource-name> 
     <url-pattern>/*</url-pattern> 
    </web-resource-collection> 
    <user-data-constraint> 
     <transport-guarantee>CONFIDENTIAL</transport-guarantee> 
    </user-data-constraint> 
</security-constraint> 

因此,如果用戶使用HTTP訪問從瀏覽器應用程序:// ...,這將是「重定向」到https:// .. 。

注意:您也紛紛來配置Wildfly安全領域SSL,但我假設你已經做到了

+0

謝謝,它爲我工作。 – Navin