Binding nginx to a single interface

Maxim Dounin mdounin at
Thu Feb 9 23:34:20 UTC 2012


On Thu, Feb 09, 2012 at 01:06:14PM -0500, Bai Shen wrote:

> They do.
> However, I do have some weird behaviour.  I have the server_name set to
> and that correctly connects me to my web server.  But if I
> type in, that connects me to my web server as well, even though I
> don't have a default rule setup.
> When I go to I get a "Welcome to nginx!" page.

When selecting server{} based on server_name nginx will look only 
through server{} blocks which have the listen socket defined.

That is, if you have

    server {
        listen 80;
        server_name default;

    server {

nginx will never consider "default" server if connection comes to  All requests to will end up in 
"" server as it's the only server defined for the 
listen socket in question.

More details may be found here:

and in docs.

Maxim Dounin

More information about the nginx mailing list