Configured Subdomain with nginx always gives warning

Evils asked:

I’m trying to configure a subdomain on my root server.
As I want to use this subdomain on port 80, I added another serverblock to the corresponding config file.

Everytime I start nginx now I get the following error:

nginx: [warn] conflicting server name "domain.de" on 0.0.0.0:80, ignored

This is my config file:

server {
    listen 80;
    server_name domain.de *.domain.de;
    rewrite ^(.*) http://domain.de$1 permanent;
}

server {
    listen 80;

    server_name domain.de;

    root /var/www_80;
[...]

}

server {
    listen   80; ## listen for ipv4; this line is default and implied

    server_name cdn.domain.de;

    root /var/domain_streams;
[...]

}

If I visit my cdn.domain.de I get redirect to the correct site and the correct server part works, but I’m still getting this strange warning.

Can I just ignore it, or am I doing something wrong?

My answer:


You have server_name domain.de defined in two different server blocks. Since the intent of one of them is to redirect traffic to domain.de, having it there is clearly erroneous.


View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.