0

I am having an NGINX emergency where multiple websites are correctly defined as hosts with their URL set. The problem is when I make a default handler in NGINX all the SSL connections get redirected and fail. HTTP still works correctly with the default handler. I have specifically set server_name and yet it still redirects to default_sever.

server {
    listen       80  default_server;
    server_name  _;
    return       444;
}
server {
    listen       443 ssl default_server;
    server_name  _;
    return       444;
}
Ozfer
  • 1
  • 1
  • There are no redirects in the configuration you posted. – Michael Hampton Jul 06 '18 at 14:58
  • I didn't add the part for my websites since they work without the above code. I am assuming it is in the default_server implementation. – Ozfer Jul 06 '18 at 15:11
  • Have you configured ssl for your default server? What is the server name, is it an ip or a domain? – Ajay Singh Jul 06 '18 at 23:40
  • We cannot provide any answer without seeing the complete configuration, since it is the combination of all configuration items that define the behaviour of the system. – Tero Kilkanen Jul 07 '18 at 08:06

1 Answers1

0

This kind of behavior might be due to incorrect configuration of SSL certificates. Try adding some kinds of certificates, like in this answer.

In my case, there was also something else missing:

ssl_session_tickets off;

Don't ask me why, without it the whole nginx was just broken. Nginx version 1.12.2.

The whole working example:

server {
    listen 443 ssl http2 default_server;
    listen [::]:443 ssl http2 default_server;
    server_name _;

    ssl_certificate /etc/nginx/ssl/nginx.crt;
    ssl_certificate_key /etc/nginx/ssl/nginx.key;
    ssl_session_tickets off;
    return 404;
}
Marek Lisý
  • 151
  • 1
  • 3