a duplicate default server for 0.0.0.0:80 in /etc/nginx/nginx.conf:39

Kaushal Shriyan kaushalshriyan at gmail.com
Tue Nov 24 18:10:53 UTC 2020


Hi,

I have two nginx.conf file /etc/nginx/conf.d/onetest.conf
and /etc/nginx/nginx.conf. Basically the first config file works without
any issue while redirecting from port 80 to 443. I want to enable the port
redirect from port 80 to 443 in /etc/nginx/nginx.conf. when I add the below
block in /etc/nginx/nginx.conf, I am facing *a duplicate default server for
0.0.0.0:80 <http://0.0.0.0:80> in /etc/nginx/nginx.conf:39 * I

      listen       80 default_server;
      server_name abtddeveloperportal.mydomain.com;
      return       301 https://$server_name$request_uri;
}


####################################cat
/etc/nginx/conf.d/onetest.conf######################################################################
cat /etc/nginx/conf.d/onetest.conf
server {
      listen       80 default_server;
      server_name  onetest.mydomain.io;
      return       301 https://$server_name$request_uri;
}


server {
        listen 443 ssl;
        server_name onetest.mydomain.io;
        ssl_protocols          TLSv1.3 TLSv1.2;
        ssl_certificate /etc/ssl/onetest.mydomain.io/fullchain1.pem;
ssl_certificate_key /etc/ssl/onetest.mydomain.io/privkey1.pem;
        ssl_ciphers
ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
        ssl_prefer_server_ciphers on;
        ssl_dhparam /etc/ssl/onetest.mydomain.io/dhparam.pem;
        client_max_body_size 100M;
        root         /var/www/newtheme/testuatplace-v2/mpV2/web/;


location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

#####################################################################################################################################


####################################cat
/etc/nginx/nginx.conf######################################################################


    server {
      listen       80 default_server;
      server_name abtddeveloperportal.mydomain.com;
      return       301 https://$server_name$request_uri;
}


    server {
        listen 443 ssl;
        server_name abtddeveloperportal.mydomain.com;
        ssl_protocols          TLSv1.3 TLSv1.2;
        ssl_certificate /etc/ssl/
abtddeveloperportal.mydomain.com/fullchain3.pem; ssl_certificate_key
/etc/ssl/abtddeveloperportal.example.com/privkey3.pem;
        ssl_ciphers
ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
        ssl_prefer_server_ciphers on;
        ssl_dhparam /etc/ssl/abtddeveloperportal.mydomain.com/dhparam.pem;
        client_max_body_size 100M;
        #listen       [::]:80 default_server;
        root         /var/www/drupal/testplace-v2/mpV2/web;
#######################################################################################################################################################


#nginx -t -c /etc/nginx/nginx.conf
nginx: [emerg] a duplicate default server for 0.0.0.0:80 in
/etc/nginx/nginx.conf:39
nginx: configuration file /etc/nginx/nginx.conf test failed

Is there a way to enable redirect from port 80 to 443 for both
/etc/nginx/conf.d/onetest.conf and /etc/nginx/nginx.conf files.  Any help
will be highly appreciated.

Thanks in Advance.

Best Regards,

Kaushal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20201124/538f4ef7/attachment.htm>


More information about the nginx mailing list