Skip to content

Instantly share code, notes, and snippets.

@noodny
Created June 8, 2015 05:28
Show Gist options
  • Select an option

  • Save noodny/681521329d6ee25780e9 to your computer and use it in GitHub Desktop.

Select an option

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

axelitus commented Jun 10, 2018

Copy link
Copy Markdown

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