Skip to content

Instantly share code, notes, and snippets.

@noodny
Created June 8, 2015 05:28
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noodny/681521329d6ee25780e9 to your computer and use it in GitHub Desktop.
Save noodny/681521329d6ee25780e9 to your computer and use it in GitHub Desktop.
Disable default server in nginx
server {
listen 80 default_server;
server_name _;
deny all;
}
@axelitus
Copy link

axelitus commented Jun 10, 2018

I would add return 444; to the configuration (to prevent nginx from returning the 403 Response):

The complete configuration would be:

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    server_name _;
    deny all;
    return 444;
}

That way the server closes the connection and it's as if there were no server at all. (The IPv6 part is just for completeness).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment