Server_name behaviour

Hi

A couple of us in the IRC channel are keeping the wiki updated and we’ve
come across some inconsistent behaviour with server_name.

The wiki currently states here:
http://wiki.nginx.org/NginxHttpCoreModule#server_name
that server_name _; is treated specially for requests with no Host
header, however, on the latest dev version this is not so.

If a request on the IP or on a domain without a matching server_block
comes in then Nginx will either choose the server block with
default_server flag in listen or the first one defined.

Question is, is this is a bug or should we update the wiki to no longer
mention _?

Sincerely,
Martin Fjordvald

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,130108,130108#msg-130108

On Mon, Sep 13, 2010 at 02:47:58PM -0400, Ensiferous wrote:

If a request on the IP or on a domain without a matching server_block
comes in then Nginx will either choose the server block with
default_server flag in listen or the first one defined.

Question is, is this is a bug or should we update the wiki to no longer
mention _?

Please read this:
http://nginx.org/en/docs/http/server_names.html#miscellaneous_names


Igor S.
http://sysoev.ru/en/

Thank you, will update the wiki to match.

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,130108,130118#msg-130118

On 13.09.2010 21:53, Igor S. wrote:

Please read this:
http://nginx.org/en/docs/http/server_names.html#miscellaneous_names

but “server_name _;” directive is no more required
in catch-all server for nignx version 0.8.48 and newer.

======================================================================

In catch-all server examples you may see the strange name “_”:

server {
listen 80 default_server;
server_name _;
return 444;
}

There is nothing special about this name, it is just one of a myriad of
invalid domain names which never intersect with any real name. You may
also use something like “–”, “[email protected]#”, and so on.

======================================================================

and nginx users should not use hack “server_name _;” in 0.8.48+ (?)
probably this documentation fragment is slightly out-of-date ?


Best regards,
Gena

On Mon, Sep 13, 2010 at 10:19:34PM +0300, Gena M. wrote:

In catch-all server examples you may see the strange name “_”:

======================================================================

and nginx users should not use hack “server_name _;” in 0.8.48+ (?)
probably this documentation fragment is slightly out-of-date ?

It probably requires some rewording, but I think if a reader reads from
the start of “Miscellaneous names” section, he should understands “_”
usage.
An empty name may be a good server name, which should not handled by
default server.


Igor S.
http://sysoev.ru/en/

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs