Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On a simple Tomcat 7 installation with HTTPS, sending an HTTP request on the HTTPS port returns a strange response of three control characters:

$ wget -q -S -O -

[I have used caret-char combination as I can't paste the original.]

If possible I want to change it to redirecting to https or return 404 or some other custom behavior. Is this possible?

share|improve this question
You would need something that could autodetect whether the client was using SSL. – David Schwartz Aug 14 '13 at 22:02
up vote 0 down vote accepted

Sending HTTP on HTTPS dedicated port is not expected normally, though possible. In practice, production is running on 80 and 443 ports, so that is not really an issue unless somebody is sort of "hacking". In case different ports are used (eg. default Tomcat's) then the problem might arise just because people will forget to type "https" in front of URL.

In any case standard behavior is to return HTTP 400 Bad Request. This is done eg. by Apache web server.

<title>400 Bad Request</title>
<h1>Bad Request</h1>
<p>Your browser sent a request that this server could not understand.<br />
Reason: You're speaking plain HTTP to an SSL-enabled server port.<br />
Instead use the HTTPS scheme to access this URL, please.<br />

Tomcat TLS/SSL HTTP connector doesn't do this obviously, and I suspect that it replies with some TLS handshake error message (discussed partially here

In production, SSL is usually terminated on reverse proxy server (such as Apache) which handles even such a bad request gracefully (as described above).

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .