2015-12-02 36 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