Multiple server_name entries not working

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 / {
   index index.htm index.html;
 }

}

Requests for ‘domain.com’ return the correct index page but requests for
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

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

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

}

Requests for ‘domain.com’ return the correct index page but requests for
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 www.domain.com;
what does “nginx -t” show ?


Igor S.

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

If you set server_name domain.com 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

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:
http://forum.nginx.org/read.php?2,202461,202582#msg-202582

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