0

I am newbie to tomcat, in that case i had my website to work under

http://myserver:8080/path/login/login.html

I wanted to activate https with the port 8443

https://myserver:8443/path/login/login.html

I lunch tomcat under an common user, with the configuration below on server.xml, the url:8443 is working with my ssl certificate and url:8080 is no more working. Is this normal that http mode is no more working ? And please how can i do my redirection by itself to https ? with the famous bloc into web.xml ?

<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" />


<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
               compression="on"
               compressionMinSize="2048"
               compressableMimeType="text/html,text/xml,text/plain,text/css,text/javascript,text/json,application/x-javascript,application/javascript,application/json" />


<Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol"
               maxThreads="150" SSLEnabled="true">
        <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" />
        <SSLHostConfig>
            <Certificate certificateKeyFile="conf/cert.key"
                         certificateFile="conf/cert.crt"
                         type="RSA" />
        </SSLHostConfig>
    </Connector>

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Many thanks

1

No, all connectors should work independently. Make sure to stop running Tomcat instances before restarting Tomcat and check if the port is not used by another application.

Also check your catalina.log after startup, it should contain one log message for each port like this:

04-Dec-2020 19:24:16.658 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
04-Dec-2020 19:24:16.750 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["https-openssl-apr-8443"]
04-Dec-2020 19:24:16.782 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
04-Dec-2020 19:24:16.825 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [8,729] milliseconds

To redirect all requests for all webapps from HTTP to HTTPS, add this snippet to the end of your conf/web.xml (in your CATALINA_BASE or CATALINA_HOME directory) before the last line </web-app>:

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

The transport-guarantee value CONFIDENTIAL means that all URLs matching the pattern /* are using a secure connection, i.e. non-SSL requests are redirected to the redirectPort defined in your connector settings.

3
  • The only errors i see into log is INFOS [http-nio-8080-exec-3] org.apache.coyote.http11.Http11Processor.service Error parsing HTTP request header Note: further occurrences of HTTP header parsing errors will be logged at DEBUG level. java.lang.IllegalArgumentException: Invalid character found in method name. HTTP method names must be tokens – Peutre Dec 8 '20 at 13:31
  • thanks for your help, i went for the code into the web.xml Using chrome/firefox it work with going app-test.domain.fr:8080/app/login/login.html redirect well to app-test.domain.fr:8443/app/login/login.html But it's not working with Edge Now it's no more working after two attempts, app-test.domain.fr:8080/app/login/login.html redirect to app-test.domain.fr:8080/app/login/login.html – Peutre Dec 8 '20 at 13:54
  • the final test after all is that http goes to https automatically but staying with the port 8080 and not 8443. It's only working with Internet explorer but not with others, chrome/firefox – Peutre Dec 8 '20 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.