I have a private HTTPS server using nginx. Therefore, I don't care about browser compatibility nor HTTP to HTTPS redirection; I just want it to work in my environment and nowhere else. I have already configured it with "listen 17648 ssl;". Whenever I try to connect to it using plain HTTP, I get the infamous "The plain HTTP request was sent to HTTPS port" response.
Is there any way to prevent nginx from sending any response at all when a HTTP request is sent to a HTTPS port? I would like nginx to simply close the connection if the request is not SSL, or maybe return some SSL-level error but no plain HTTP response at all, not even an error response.
Best Answer
From Nginx documentation about the return clause:
So I've tried to catch the error 497 "HTTP to HTTPS" and tried to return the 444 this way:
Unfortunately this leads to a "pending" state due to this bug
Using the workaround proposed by the developer it seems to work:
Try if this fits your needs!