Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I've looked at all <a href="https://serverfault.com/questions/47876/handling-http-and-https-requests-using-a-single-port-with-nginx#comment-37501">answers</a> over there and they tell almost the same: it is impossible because of the differences between HTTP and HTTPS. Even browsers use different default ports for handling HTTP/HTTPS.</p> <p>Why this is happening: HTTP is basically text protocol, and browsers just sends HTTP (text) headers over TCP-IP. HTTPS isn't just SSL over HTTP. First of all browser performs "handshake", then it receives from server certificate, and all information from server to browser and vice versa is being encoded with symmetric keys negotiated during the handshake.</p> <p>Because of 2 keys (public and private), which is used in asymmetric encryption, nobody (except who knows private key) can't sniff or change the information.</p> <p><em>Experiment</em>: try to do following: change <strong>https</strong> to <strong>http</strong> and explicitly add "443" in the end (something like <em><a href="http://google.com:443" rel="nofollow noreferrer">http://google.com:443</a></em>) You've got either "The connection was reset" or suggestion to store binary file (e.g. certificate).</p> <p><strong>Note</strong>: usually servers are set to reject such requests.</p> <p>So even if you use the same connector to handle both HTTP and HHTPS connections, you are supposed to use different connection handlers (we faced with this when were implementing high-load server based on Netty).</p> <p>And the only possibility to use HTTP and HTTPS on the same port is with using "magic recognizer", which would check either plain text has come or binary handshake. If we put that recognizer on the container's side (Glassfish protocol handler), it would have quite big performance overhead (checking each request whether it SSL or not!). If we put it on the proxy server's side (e.g. nginx or other non-blocking servers, such as Netty) performance wouldn't suffer too much, but anyway this doesn't guarantee 100% of success.</p> <p><em>Note</em>: that proxy server just recognizes, and after that it forwards request to 2 different ports!</p> <p>As a conclusion: in general, it's possible, but from my point of view, the needed work doesn't worth the result.</p> <p><strong>EDIT</strong>: As @Bruno answered, there is present <em>magic recognizer</em> out of the box, but it is not <em>officially</em> supported by Glassfish.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload