Linux – How to setup 404 nginx config for default host on port 443

linuxnginxport-443ssl-certificate-errors

For the past few weeks I am hunting for a solutions to setup 404 nginx config for default host on port 443. And no solution so far.

To clarify the question properly. Lets take quora.com as example which is running on nginx.

Now Quora.com's public ip is 192.229.182.210 and when you enter the following it shows the following results

http://192.229.182.210 – shows 404
https://192.229.182.210 – Server could be tricking -> then shows 404

Hint – Most other servers running on nginx, says invalid certificate and then forwards to its production host. Example – wordpress.org

The question is should you use a ssl snippet on the default config to pass the 404 as quora's public https ip shows? If yes, was it self signed? If no ssl used, how is it done?

My current config is

server {
listen 80 default_server;
listen [::]:80 default_server;

server_name _;

return 403;
}

Best Answer

https://192.229.182.210 shows a certificate warning in Chrome, IE, and Firefox. Perhaps you added an exception that allows it to ignore the certificate mismatch, or you're using a strangely permissive browser. If you're not seeing this clear your cache and exceptions, refresh, and provide a screenshot if it's still happening.

What I describe above is the expected behavior because https certificates are issued against a domain name, not an IP.

I don't think it's possible to display a page based on https requests to your IP without a domain name without getting a certificate warning. That would require an https certificate to be issued to an IP, which is possible but is very rarely done.