You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Robert Sulliman <ro...@sjrb.ca> on 2016/07/07 13:33:16 UTC

Issue with redirects

Greetings,

I'm having some difficulty with redirects on a new Tomcat setup I'm working on, hoping I can find some help here on what I'm missing.

As you can see below, I have setup a redirect from port 8080 to 8443. When I load the hostname or localhost of the server on http://localhost.mydomain.ad:8080 I get redirected to https://localhost.mydomain.ad:8443, great. However I have another A record defined for this host which I have under the alias tag below (dev.registration.mydomain.ca). When I load https://dev.registration.mydomain.ca:8443 everything works fine, but if I load http://dev.registration.mydomain.ca:8080 I get redirected to https://dev.registration.mydomain.ca:8080 which obviously doesn't work since the port didn't change... Why is this working with the localhost but not with the A record I entered? I feel like I'm missing something obvious, and maybe I'm not asking Google the right questions, any advice would be welcome!

Tomcat Version - 8.0.36
Java Version - 1.8.0_91-b14
OS - RHEL_7.2

This is my server.xml:
________________________________
<?xml version='1.0' encoding='utf-8'?>
<Server port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <GlobalNamingResources>
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>

  <Service name="Catalina">

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

    <Connector protocol="org.apache.coyote.http11.Http11Nio2Protocol"
               port="8443" maxThreads="200"
               scheme="https" secure="true" SSLEnabled="true"
               keystoreFile="/usr/local/tomcat/conf/servercert.jks" keystorePass="MyPassword"
               sslEnabledProtocols="TLSv1.2" clientAuth="false" sslProtocol="TLS" />

  <Engine name="Catalina" defaultHost="localhost">

  <Realm className="org.apache.catalina.realm.LockOutRealm">
  <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
  </Realm>

      <Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">

     <alias>dev.register.mydomain.ca</alias>

      <Context path="" docBase="registration-portal" reloadable="true" debug="0" cookies="false"></Context>

      <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t &quot;%r&quot; %s %b" />

      </Host>
    </Engine>
  </Service>
</Server>
________________________________

This is what I have added to my web.xml:
________________________________
<security-constraint>
    <web-resource-collection>
        <web-resource-name>registration-portal</web-resource-name>
        <url-pattern>/*</url-pattern>
    </web-resource-collection>

    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>
________________________________

Thanks!
Robert