preventing requests with unknown host names

Francis Daly francis at
Thu Aug 20 22:16:57 UTC 2015

On Thu, Aug 20, 2015 at 02:46:57PM -0700, Igal @ wrote:
> I want to disable processing of all requests that do not have a valid
> hostname

Check your entire configuration for "listen" directives.

There will be zero or more in each server{} block. If there are zero,
that is equivalent to "listen 80" (if you run as root).

For each "listen" directive with a unique ip:port, add one server{}
block which contains "listen ip:port default_server; return 444;"

> I'm tried to follow the advice on:
> so I have (inside http directive):
>     server {
>         listen      80;
>         server_name "";
>         return      444;
>     }

If your config only has "listen 80", or no "listen" directives at all, then

  server {
    listen 80 default_server;
    return 444;

should do what you want.

> but I am still able to access the website by its IP address?
> what am I doing wrong?

Not causing that server to be the default server for the ip:port you
are connecting to.

Francis Daly        francis at

More information about the nginx mailing list