Tomcat8 redirect http://8080 to https://8443 not working - instead https://8080

331 Views Asked by At

We want to redirect http://8080 to https://8443 with Tomcat 8. Unfortunately we come accross the situation that http://server:8080is redirected to https://server:8080 instead of https://server:8443. I have updated server.xml as well as web.xml - showing below - However the port within the URL is not updated.

When the cache is cleaned (in any browser) then the first URL redirect works as expected while the second one fails again. However, when entering http://server:8080/ as URL again it gets redirected to the wrong URL https://server:8080/ again while the port does not change.

conf/server.xml

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443"
           maxPostSize="8388608" />

<Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol"
           maxThreads="150" SSLEnabled="true"
           scheme="https" secure="true"
           clientAuth="false" sslProtocol="TLS"
           maxPostSize="8388608"
           ... Certificate settings...
           URIEncoding="UTF-8"
           compression="force"
           compressableMimeType="text/html,text/xml,text/plain,text/javascript,text/css"/>

conf/web.xml

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

There are 0 best solutions below