Bhargav Teja
Bhargav Teja

Reputation: 451

How to redirect http to https in JBoss EAP 6.4?

Here how to set substitution to any address so that I can use it in AWS Application Load Balancer.

<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https"  enable-lookups="false" secure="true" />
<virtual-server name="default-host" enable-welcome-root="true">
    <rewrite pattern="^/(.*)$" substitution="https://localhost:443/$1" flags="RL">
        <condition test="%{HTTPS}" pattern="off" />
    </rewrite>               
    <alias name="localhost"/>
    <alias name="example.com"/>
</virtual-server>

I want like

<rewrite pattern="^/(.*)$" substitution="https://%HOST_NAME%" flags="RL">
    <condition test="%{HTTPS}" pattern="off" />
</rewrite>

Upvotes: 1

Views: 5076

Answers (2)

PrecisionLex
PrecisionLex

Reputation: 883

This is what worked for me (change in configruation/standalone-full.xml):

        <filters>
            <rewrite name="http-to-https" target="https://${jboss.qualified.host.name}:8443%U" redirect="true"/>
        </filters>

Upvotes: 0

Viral Gohel
Viral Gohel

Reputation: 316

Here are the steps to redirect from http to https in EAP 6,

Add redirect-port="443" to http connector as follows :

<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" redirect-port="443"/>

Change the socket-binding of https to 443 as follows :

<socket-binding name="https" port="443"/>

Configure https connector in EAP 6,

 <connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
                <ssl name="ssl" key-alias="mykey" password="password" certificate-key-file="/path/to/keystore.jks"/>
        </connector>

Edit the web.xml of application as follows:-

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

    </web-app>

Upvotes: 2

Related Questions