nginx conflicting server name

23 Views Asked by At

i have /etc/nginx/sites-available/one:

server {

        root /var/www/wsaio/;
        index index.html index.htm index.nginx-debian.html;

        server_name server.zaifuuu.me www.server.zaifuuu.me;


        location / {
            proxy_set_header  X-Real-IP  $remote_addr;
            proxy_set_header  Host       $http_host;
            proxy_pass        http://127.0.0.1:4900/;
        }

    listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/server.zaifuuu.me/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/server.zaifuuu.me/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 = server.zaifuuu.me) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80;
        listen [::]:80;

        server_name server.zaifuuu.me www.server.zaifuuu.me;
    return 404; # managed by Certbot


}

According to me, this file is set for requests on my node server running on port 4900 at localhost. And it is configured to use ssl certificate for https redirections. there are two ports defined here 443 and 80 for https and http hits. I dont know if I am getting this wrong in some way or is this some random error. Same goes for the second file.
and /etc/nginx/sites-available/two:

server {

        root /var/www/zaif/live-build/;
        index index.html index.htm index.nginx-debian.html;

        server_name zaifuuu.me www.zaifuuu.me; 


        location / {
            try_files $uri $uri/ /index.html;
            # proxy_set_header  X-Real-IP  $remote_addr;
            # proxy_set_header  Host       $http_host;
            # proxy_pass        http://127.0.0.1:3000/;
        }

    # listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/zaifuuu.me/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/zaifuuu.me/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 = zaifuuu.me) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


        listen 80;
        listen [::]:80;

        server_name zaifuuu.me www.zaifuuu.me;
    return 404; # managed by Certbot


}

when I do nginx -t it gives me:

nginx: [warn] conflicting server name "server.zaifuuu.me" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www.server.zaifuuu.me" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "www.zaifuuu.me" on 0.0.0.0:80, ignored
nginx: [warn] conflicting server name "server.zaifuuu.me" on [::]:80, ignored
nginx: [warn] conflicting server name "www.server.zaifuuu.me" on [::]:80, ignored
nginx: [warn] conflicting server name "www.zaifuuu.me" on [::]:80, ignored
nginx: [warn] conflicting server name "server.zaifuuu.me" on [::]:443, ignored
nginx: [warn] conflicting server name "www.server.zaifuuu.me" on [::]:443, ignored
nginx: [warn] conflicting server name "server.zaifuuu.me" on 0.0.0.0:443, ignored
nginx: [warn] conflicting server name "www.server.zaifuuu.me" on 0.0.0.0:443, ignored
nginx: [warn] conflicting server name "www.zaifuuu.me" on 0.0.0.0:443, ignored
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Actually I am more at a learning phase and I could not find the exact reason why is this error being thrown and what are the positive or negative effects of these errors or ignorance of these errors.

0

There are 0 best solutions below