# Server\_name behaviour

**URL:** <https://www.ruby-forum.com/t/server-name-behaviour/194920>\
**Category:** NGINX\
**Created:** [September 13, 2010, 8:48pm UTC](https://www.ruby-forum.com/t/server-name-behaviour/194920 "2010-09-13T20:48:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ensiferous](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e274bd/32.png) [@Ensiferous](https://www.ruby-forum.com/u/Ensiferous)\
**Post date:** [September 13, 2010, 8:48pm UTC](https://www.ruby-forum.com/t/server-name-behaviour/194920/1 "2010-09-13T20:48:32Z")

</div>

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](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:

> **[server\_name behaviour](https://forum.nginx.org/read.php?2,130108,130108#msg-130108)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![Ensiferous](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e274bd/32.png) [@Ensiferous](https://www.ruby-forum.com/u/Ensiferous)\
**Post date:** [September 13, 2010, 8:53pm UTC](https://www.ruby-forum.com/t/server-name-behaviour/194920/2 "2010-09-13T20:53:48Z")

</div>

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:

> **[Server names](http://nginx.org/en/docs/http/server_names.html#miscellaneous_names)**
>
> Server names are defined using the server\_name directive and determine which server block is used for a given request. See also “How nginx processes a request”. They may be defined using exact names, wildcard names, or regular expressions:

–  
Igor S.

> **[Igor Sysoev](http://sysoev.ru/en/)**

---

<div class="post-metadata">

**Author:** ![Ensiferous](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e274bd/32.png) [@Ensiferous](https://www.ruby-forum.com/u/Ensiferous)\
**Post date:** [September 13, 2010, 9:14pm UTC](https://www.ruby-forum.com/t/server-name-behaviour/194920/3 "2010-09-13T21:14:18Z")

</div>

Thank you, will update the wiki to match.

Posted at Nginx Forum:

> **[Re: server\_name behaviour](https://forum.nginx.org/read.php?2,130108,130118#msg-130118)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![Ensiferous](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e274bd/32.png) [@Ensiferous](https://www.ruby-forum.com/u/Ensiferous)\
**Post date:** [September 13, 2010, 9:20pm UTC](https://www.ruby-forum.com/t/server-name-behaviour/194920/4 "2010-09-13T21:20:45Z")

</div>

On 13.09.2010 21:53, Igor S. wrote:

> Please read this:  
> [Server names](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 â€œ–â€, â€œ!@#â€, 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

---

<div class="post-metadata">

**Author:** ![Ensiferous](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e274bd/32.png) [@Ensiferous](https://www.ruby-forum.com/u/Ensiferous)\
**Post date:** [September 13, 2010, 9:32pm UTC](https://www.ruby-forum.com/t/server-name-behaviour/194920/5 "2010-09-13T21:32:27Z")

</div>

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.

> **[Igor Sysoev](http://sysoev.ru/en/)**
