Score:1

Nginx conflicting server name in server block configuration

ly flag

After getting certbot certificates i get the following error when doing nginx -t :

nginx: [warn] conflicting server name "naos-soultrap.online" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www.naos-soultrap.online" on 0.0.0.0:80,ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Here is my server block configuration :

server {

    server_name naos-soultrap.online www.naos-soultrap.online;

    root /home/pierre/public/naossoultrap;

    index index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }

    listen [::]:443 ssl http2 ipv6only=on; # managed by Certbot
    listen 443 ssl http2; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/escapingthematrix.online/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/escapingthematrix.online/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot


}
server {
    if ($host = www.naos-soultrap.online) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    if ($host = naos-soultrap.online) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


     listen 80;
     listen [::]:80;
     server_name naos-soultrap.online www.naos-soultrap.online;
     return 404; # managed by Certbot
}
server {
    if ($host = naos-soultrap.online) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;

    server_name naos-soultrap.online www.naos-soultrap.online;
    return 404; # managed by Certbot


}
Peter Tremblay avatar
ly flag
The copy paste for code did not work correctly , i chose the code bracket and paste my config in it but it doesn't display correctly.
Score:0
sb flag

Your warning literally tell you what is wrong with the config:

nginx: [warn] conflicting server name "naos-soultrap.online" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www.naos-soultrap.online" on 0.0.0.0:80, ignored 

Two of your server configurations (which you have three of in total) have conflicting names.

The first server block is for https/443:

server {

    server_name naos-soultrap.online www.naos-soultrap.online;
    root /home/pierre/public/naossoultrap;
    index index.html index.htm;

    location / {
        try_files $uri $uri/ =404;
    }

    listen [::]:443 ssl http2 ipv6only=on; # managed by Certbot
    listen 443 ssl http2; # managed by Certbot
    
    ssl_certificate /etc/letsencrypt/live/escapingthematrix.online/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/escapingthematrix.online/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
} 

After that you have two http/80 server blocks with identical server names and if we look close enough we can notice that the second http/80 server block here is redundant and in fact doesn't add any new configuration on top of the first server http/80 block. I would assume you can safely remove it.

server { 
    if ($host = www.naos-soultrap.online) { 
        return 301 https://$host$request_uri; 
    } # managed by Certbot

    if ($host = naos-soultrap.online) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    listen [::]:80;
    server_name naos-soultrap.online www.naos-soultrap.online;
    return 404; # managed by Certbot
} 

server { 
    if ($host = naos-soultrap.online) { 
        return 301 https://$host$request_uri; 
    } # managed by Certbot

    listen 80;

    server_name naos-soultrap.online www.naos-soultrap.online;
    return 404; # managed by Certbot
}
Peter Tremblay avatar
ly flag
Thank you very much that solved the issue. Regards Peter
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.