Score:0

Apache Tomcat Accept HTTP and HTTPS on same port and always redirect to HTTPS

th flag

Hi I have the following connector in my apache tomcat server in the file server.xml:

 <Connector port="8443" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443"
               secure="true"
               SSLEnabled="true"
               scheme="https"
               keystoreFile="/opt/tomcat/resources/keystore.jks"
               keystorePass="secret"
               clientAuth="false"
               sslProtocol="TLS"
    />

If you visit the Site via the url https://mysite:8443/webapp I get a secure TLS Connection and everything works.

But some of my coworkers manually type http://mysite:8443/webapp and get the error:

Bad Request This combination of host and port requires TLS.

This error makes sense to me. But I need that if you make a HTTP Request on the Port 8443 that this Request gets redirected to a HTTPS Request. So that I user can Type HTTP and will get redirected to HTTPS automatically.

Is there a way to achieve this behavior in Apache Tomcat/9.0.73.

vidarlo avatar
ar flag
Does this answer your question? [Apache answer both HTTP and HTTPS on the same port](https://serverfault.com/questions/359461/apache-answer-both-http-and-https-on-the-same-port)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.