Search code examples
javahttpswildfly-8ear

Port Unification in Wildfly-8.2.1


I have an EAR application having structure like,

abc.ear

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

The application is running fine on a Wildfly server separately as,

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

I want to redirect all the HTTP (Port 8080) requests to the HTTPS (Port 8443).
Any help is heartily appreciated.


Solution

  • If I understand correctly, you have a webapp packaged in an EAR file. So you could add this in webapp 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>
    

    Thus if a user access your application from its browser using http://..., it will be "redirected" to https://...

    Note: You have also to configure SSL in Wildfly security-realms but I assume you already did it