luki512
luki512

Reputation: 237

nginx conflicting server name, but different ports

My plan was to do a simple Nginx setup with redirections for URLs without the subdomain "www" and without port 443. The problem is that I get the following warning as output:

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

I don't really get why there is a conflicting server name if the domains are on separate ports. Is there a workaround of do I miss something?

server {
        server_name www.domain.de;
        root /var/www/folder/;
        index index.php;


        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/domain.de/fullchain.pem; 
        ssl_certificate_key /etc/letsencrypt/live/domain.de/privkey.pem; 
        include /etc/letsencrypt/options-ssl-nginx.conf; 
        ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; 

}

server {
    if ($host = www.domain.de) {
        return 301 https://www.domain.de$request_uri;
    }

    if ($host = domain.de) {
        return 301 https://www.domain.de$request_uri;
    }


    listen 80;
    server_name www.domain.de domain.de;
    return 404;
}


server {
    if ($host = domain.de.de) {
        return 301 https://www.domain.de$request_uri;
    }

    listen 443 ssl; 
    ssl_certificate /etc/letsencrypt/live/domain.de.de/fullchain.pem; 
    ssl_certificate_key /etc/letsencrypt/live/domain.de.de/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf; 
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; 

    server_name domain.de;
    return 404;
}

Best regards

Upvotes: 0

Views: 1421

Answers (1)

luki512
luki512

Reputation: 237

For some reason certbot created a redirect in the default config. Never had this issue before. After I removed the duplicated code it worked.

Upvotes: 1

Related Questions