Welcome! Log In Create A New Profile

Advanced

Return 444 if https port(443) accesed via http

Posted by chintans 
Return 444 if https port(443) accesed via http
February 14, 2017 12:27PM
Hi All,

I am new to nginx and trying to port my app from Apache, I did google and gone through docs unfortunately not able to achieve below requirement.

If user access website for e.g. http://www.abc.com:443 then I would like to return 444, as of now nginx default 400 error page is returned. "The plain HTTP request was sent to HTTPS port
"

server block -
server {
listen 1.1.1.1:443 ssl;
server_name abc.com;
}

Thanks !
Re: Return 444 if https port(443) accesed via http
February 17, 2017 04:14PM
It won't work if you use "ssl" in the listen directive and don't define an ssl certificate and key. You'll see something like this in the error log:

"no "ssl_certificate" is defined in server listening on SSL port while SSL handshaking"

The surest way would be to create a custom error page.

Or perhaps:

server {
listen 1.1.1.1:443 ssl;
server_name abc.com;
ssl_certificate cert.pem;
ssl_certificate_key key.pem;
return 301 http://abc.com$request_uri;
}

--
Jim Ohlstein



Edited 1 time(s). Last edit at 02/17/2017 04:29PM by Jim Ohlstein.
Re: Return 444 if https port(443) accesed via http
February 24, 2017 02:20AM
Thanks Jim !
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 129
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready