# Multiple server\_name entries not working

**URL:** <https://www.ruby-forum.com/t/multiple-server-name-entries-not-working/207659>\
**Category:** NGINX\
**Created:** [May 31, 2011, 3:14am UTC](https://www.ruby-forum.com/t/multiple-server-name-entries-not-working/207659 "2011-05-31T03:14:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [May 31, 2011, 3:14am UTC](https://www.ruby-forum.com/t/multiple-server-name-entries-not-working/207659/1 "2011-05-31T03:14:40Z")

</div>

Nginx 1.0.3

I have a virtual host file with a simple config:

server {  
listen 8080;  
server\_name [domain.com](http://domain.com)[www.domain.com](http://www.domain.com);  
root /var/www/html/dm2011/pub;  
access\_log /var/log/nginx/access.log main;

```
 location / {
   index index.htm index.html;
 }

```

}

Requests for ‘[domain.com](http://domain.com)’ return the correct index page but requests for  
‘[www.domain.com](http://www.domain.com)’ return only the “Welcome to nginx!” page. I tried  
\*.domain.com also as the 2nd name but the result was the same. There are  
no DNS issues with both versions of the domain.

gvim

---

<div class="post-metadata">

**Author:** ![gvim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a3d4f5/32.png) [@gvim](https://www.ruby-forum.com/u/gvim)\
**Post date:** [May 31, 2011, 4:07am UTC](https://www.ruby-forum.com/t/multiple-server-name-entries-not-working/207659/2 "2011-05-31T04:07:42Z")

</div>

On Tue, May 31, 2011 at 02:14:04AM +0100, gvim wrote:

> ```
> location / {
> index index.htm index.html;
> }
> 
> ```
> 
> }
> 
> Requests for ‘[domain.com](http://domain.com)’ return the correct index page but requests for  
> ‘[www.domain.com](http://www.domain.com)’ return only the “Welcome to nginx!” page. I tried \*.domain.com  
> also as the 2nd name but the result was the same. There are no DNS issues with  
> both versions of the domain.

If you set  
server\_name [domain.com](http://domain.com)[www.domain.com](http://www.domain.com);  
what does “nginx -t” show ?

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![gvim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a3d4f5/32.png) [@gvim](https://www.ruby-forum.com/u/gvim)\
**Post date:** [May 31, 2011, 4:34am UTC](https://www.ruby-forum.com/t/multiple-server-name-entries-not-working/207659/3 "2011-05-31T04:34:58Z")

</div>

On 31/05/2011 03:07, Igor S. wrote:

> If you set server\_name [domain.com](http://domain.com)[www.domain.com](http://www.domain.com); what does “nginx  
> -t” show ?

It gave a syntax OK response. It’s mysteriously fixed now after retyping  
the line. Maybe my eyesight is going.

gvim

---

<div class="post-metadata">

**Author:** ![gvim](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/a3d4f5/32.png) [@gvim](https://www.ruby-forum.com/u/gvim)\
**Post date:** [May 31, 2011, 1:51pm UTC](https://www.ruby-forum.com/t/multiple-server-name-entries-not-working/207659/4 "2011-05-31T13:51:07Z")

</div>

Sounds like it was a browser caching issue. Browsers cache aggressively  
so always test with curl when you’re making changes.

Posted at Nginx Forum:

> **[Re: Multiple server\_name entries not working](https://forum.nginx.org/read.php?2,202461,202582#msg-202582)**
>
> Nginx 1.0.3 I have a virtual host file with a simple config: server { listen 8080; server\_name domain.com www.domain.com; root /var/www/html/dm2011/pub; access\_log /var/log/nginx/access.log main; location
