Nginx. How do I reject request to unlisted ssl virtual server?

Posted by Osw on Server Fault See other posts from Server Fault or by Osw
Published on 2012-03-27T13:26:20Z Indexed on 2012/12/06 23:06 UTC
Read the original article Hit count: 312

Filed under:
|
|
|

I have a wildcard SSL certificate and several subdomains on the same ip. Now I want my nginx to handle only mentioned server names and drop connection for others so that it'd look like nginx is not running for unlisted server names (not responding, rejecting, dead, not a single byte in response). I do the following

ssl_certificate         tls/domain.crt;
ssl_certificate_key     tls/domain.key;

server {
  listen 1.2.3.4:443 ssl;
  server_name validname.domain.com;
  //
}

server {
  listen 1.2.3.4:443 ssl;
  server_name _;
  // deny all;
  // return 444;
  // return 404;
  //location {
  //  deny all;
  //}
}

I've tried almost everything in the last server block, but no success. I get either valid response from known virtual server or error code. Please help.

© Server Fault or respective owner

Related posts about nginx

Related posts about ssl