HTTP to HTTPS redirection in JBOSS EAP 6.4: change domain name?
I have configured my web application to redirect all HTTP URL requests to HTTPS URL by making following changes:
1) Changes in standalone.xml:
<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">
<connector name="http" protocol="org.apache.coyote.http11.Http11NioProtocol" scheme="http" socket-binding="http"/>
<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
<ssl name="https" key-alias="appname" password="changeit" certificate-key-file="path_to_jks"/>
</connector>
<virtual-server name="default-host" enable-welcome-root="false">
<alias name="localhost"/>
<rewrite name="test" pattern="^:http_port/(.*)" substitution="https://hostname.domain.com:https_port/$1" flags="RL"/>
</virtual-server>
</subsystem>
2) Changes in web.xml:
<security-constraint>
<web-resource-collection>
<web-resource-name>HTTPS Constraint</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
My applications HTTP URL is:
http://hostname:http_port
My certificate file contains FQDNs (fully qualified domain names). So my HTTPS URL looks like:
https://hostname.domain.com:https_port
With current configuration, whenever user invokes HTTP URL (http://hostname:http_port), browser redirects it to:
https://hostname:https_port
But I want URL instead to redirect to:
https://hostname.domain.com:https_port
How do I do it? JBOSS version is EAP 6.4. JDK version is 1.7. Application is deployed on RHEL server. I can not set enable-welcome-root=true in standalone xml as I do not wish to change my application URL with additional contaxt.
Please let me know if you need more information.
Thanks,