Redirecting from HTTP to HTTPS

After you enable HTTPS access to Squore Server following the steps described in the section called “Accessing Squore via HTTPS”, you can automatically redirect insecure traffic to HTTPS by modifying <SQUORE_HOME>/server/standalone/configuration/standalone.xml:

  1. Find the host section of the undertow subsystem and add a filter-ref element to match URLs using the server's HTTP port:

    <host name="default-host" alias="localhost">
    	<location name="/" handler="welcome-content"/>
    	<filter-ref name="server-header"/>
    	<filter-ref name="x-powered-by-header"/>
    	<filter-ref name="http-to-https" predicate="not(equals(%A,'127.0.0.1')) and equals(%p,8180)"/>
    </host>
  2. Find the filters section of the undertow subsystem and add a rewrite element to redirect insecure requests to HTTPS:

    <filters>
    	<response-header name="server-header" header-name="Server" header-value="WildFly/10"/>
    	<response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
    	<rewrite name="http-to-https" target="https://localhost:8543%U" redirect="true"/>
    </filters>
  3. Start Squore Server and access http://localhost:8180 to verify that you are automatically redirected to https://localhost:8543.