Conflicting server name - i don't understand

Jim Ohlstein jim at ohlste.in
Wed Sep 2 04:40:33 MSD 2009


Nuno Magalhães wrote:
> I'm no expert, but may'be thi'll help...
>
> On Tue, Sep 1, 2009 at 22:51, ktm<nginx-forum at nginx.us> wrote:
>   
>> This is my vhost file.Basically for every vhost i just copy this and change domain name. What i'm missing here, why if i add the second vhost it gives me that error ?
>>     
>
> You have 3 servers{ }, not 2.
>
>   
>>  server {
>>            listen   80;
>>            server_name  www.xxx.com;
>>     
> [...]
>   
>>       }
>>     
>
> You can erase this one, and just use server_name xxx.com www.xxx.com;
> in your next server entry:
>
>   
>> server {
>>                        listen   80;
>>                        server_name xxx.com; # <-- replace
>>     
> [...]
>
> The way you have it, you have two servers for the same domain. If i'm
> not mistaken, that doesn't work correctly (and is unnecessary), unless
> one server is taking incoming requests and the other is one of the
> backend servers (thus using nginx's reverse proxy thingy).
>   

You are mistaken. I run most all of my domains as:

server   {
    listen 80;
    server_name   domain.com;
    [snip]
}

server   {
    listen 80;
    server_name   www.domain.com;
    rewrite   ^   http://domain.com$request_uri?   permanent;
}

This does not generate any errors.

(Yes, I also don't like the www prefix.)

This also is *exactly* how Igor suggested that I do it.

If I have SSL enabled, then there are two more servers for the same domain.

But even if I didn't do it that way I would still use separate servers 
for 80 and 443 for the same domain.
>   
>>            location /  {
>>                                root   /home/xxx/public_html/;
>>     
>
> Are you making vhosts for the local users? something like
> http://xxx.com/~username/ ? If so, did you check permissions?
>
> There are a lot of ifs, maybe some can be replaced. Which version are
> you running? Did you compile from source (if so with which parameters)
> of install from a package? Which OS? If all else fails, you can start
> with very basic configurations for your servers and add from there.
>
> HTH,
> Nuno Magalhães
>
>   
Jim






More information about the nginx mailing list