# Server\_name \_; doesn't work

**URL:** <https://www.ruby-forum.com/t/server-name-doesnt-work/184800>\
**Category:** NGINX\
**Created:** [March 8, 2010, 9:37pm UTC](https://www.ruby-forum.com/t/server-name-doesnt-work/184800 "2010-03-08T21:37:11Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![kleinchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b2d939/32.png) [@kleinchris](https://www.ruby-forum.com/u/kleinchris)\
**Post date:** [March 8, 2010, 9:37pm UTC](https://www.ruby-forum.com/t/server-name-doesnt-work/184800/1 "2010-03-08T21:37:11Z")

</div>

Hello, when I set a default vhosts with server\_name \_; it doesn’t work.  
Here the example file:  
server {  
listen 80;  
server\_name \_ ; # underdash means for all hosts

```
    location / {
            root /var/www/html;
            index index.html index.htm;
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
            root /var/www/html;
    }

```

}

Posted at Nginx Forum:

> **[server\_name \_; doesn't work](https://forum.nginx.org/read.php?2,61579,61579#msg-61579)**
>
> Hello, when I set a default vhosts with server\_name \_; it doesn't work. Here the example file: server { listen 80; server\_name \_ ; # underdash means for all hosts location / { root /var/www/html;

---

<div class="post-metadata">

**Author:** ![kleinchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b2d939/32.png) [@kleinchris](https://www.ruby-forum.com/u/kleinchris)\
**Post date:** [March 8, 2010, 10:28pm UTC](https://www.ruby-forum.com/t/server-name-doesnt-work/184800/2 "2010-03-08T22:28:07Z")

</div>

See this:  
[http://wiki.nginx.org/NginxHttpCoreModule#server\_name](http://wiki.nginx.org/NginxHttpCoreModule#server_name)  
And state your version and OS. Also the full config might help…

–  
() ascii-rubanda kampajno - kontraÅ­ html-a retpoÅto  
/\ ascii ribbon campaign - against html e-mail

---

<div class="post-metadata">

**Author:** ![kleinchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b2d939/32.png) [@kleinchris](https://www.ruby-forum.com/u/kleinchris)\
**Post date:** [March 8, 2010, 10:54pm UTC](https://www.ruby-forum.com/t/server-name-doesnt-work/184800/3 "2010-03-08T22:54:27Z")

</div>

Hello!

On Mon, Mar 08, 2010 at 03:36:46PM -0500, kleinchris wrote:

> Hello, when I set a default vhosts with server\_name \_; it doesn’t work. Here the example file:  
> server {  
> listen 80;  
> server\_name \_ ; # underdash means for all hosts

It doesn’t “means for all hosts”. It’s just some non-existant  
name.

See here:

> **[How nginx processes a request](http://nginx.org/en/docs/http/request_processing.html)**

Maxim D.

---

<div class="post-metadata">

**Author:** ![kleinchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b2d939/32.png) [@kleinchris](https://www.ruby-forum.com/u/kleinchris)\
**Post date:** [March 9, 2010, 1:48am UTC](https://www.ruby-forum.com/t/server-name-doesnt-work/184800/4 "2010-03-09T01:48:21Z")

</div>

Ah just used, know it works but on my other server I get a rewrite for  
[marie3.briefdomain.de](http://marie3.briefdomain.de) to  
[http://www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.marie3.briefdomain.de/](http://www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.www.marie3.briefdomain.de/)  
o,o

thanks the default helped me…

Posted at Nginx Forum:

> **[Re: server\_name \_; doesn't work](https://forum.nginx.org/read.php?2,61579,61676#msg-61676)**
>
> Hello, when I set a default vhosts with server\_name \_; it doesn't work. Here the example file: server { listen 80; server\_name \_ ; # underdash means for all hosts location / { root /var/www/html;

---

<div class="post-metadata">

**Author:** ![kleinchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b2d939/32.png) [@kleinchris](https://www.ruby-forum.com/u/kleinchris)\
**Post date:** [March 9, 2010, 1:51am UTC](https://www.ruby-forum.com/t/server-name-doesnt-work/184800/5 "2010-03-09T01:51:17Z")

</div>

And I want a domain to rewrite to www.domain.tld

So that domain.tld and \*.domain.tld would be redirected to  
www.domain.tld

Posted at Nginx Forum:

> **[Re: server\_name \_; doesn't work](https://forum.nginx.org/read.php?2,61579,61677#msg-61677)**
>
> Hello, when I set a default vhosts with server\_name \_; it doesn't work. Here the example file: server { listen 80; server\_name \_ ; # underdash means for all hosts location / { root /var/www/html;

---

<div class="post-metadata">

**Author:** ![kleinchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b2d939/32.png) [@kleinchris](https://www.ruby-forum.com/u/kleinchris)\
**Post date:** [March 9, 2010, 8:40am UTC](https://www.ruby-forum.com/t/server-name-doesnt-work/184800/6 "2010-03-09T08:40:23Z")

</div>

On Mon, Mar 08, 2010 at 07:50:52PM -0500, kleinchris wrote:

> And I want a domain to rewrite to www.domain.tld
> 
> So that domain.tld and \*.domain.tld would be redirected to www.domain.tld

> **[Converting rewrite rules](http://nginx.org/en/docs/http/converting_rewrite_rules.html)**

–  
Igor S.

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

---

<div class="post-metadata">

**Author:** ![kleinchris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b2d939/32.png) [@kleinchris](https://www.ruby-forum.com/u/kleinchris)\
**Post date:** [March 9, 2010, 1:34am UTC](https://www.ruby-forum.com/t/server-name-doesnt-work/184800/7 "2010-03-09T01:34:18Z")

</div>

Maxim is right.

Instead, use ‘listen 80 default;’ for that virtual host server block.

Ray.
