V
V
Vyacheslav Sad-Zhabka2019-08-30 13:16:44
Nginx
Vyacheslav Sad-Zhabka, 2019-08-30 13:16:44

What is the cause of the "nginx: [emerg] "root" directive is duplicate in..." error?

Good afternoon everyone.
I work with VDS through ISPManager. Everything is running under the control of nginx. I am trying to issue a letsencrypt certificate through Domains - WWW-domains , for which the panel gives me:

An error occurred while working with WWW domains. Web server configuration test when saving file '/etc/nginx/vhosts/www-root/MYSITE.conf' failed: nginx: [emerg] "root" directive is duplicate in /etc/nginx/vhosts/www-root/ MYSITE.conf:169 nginx: configuration file /etc/nginx/nginx.conf test failed

The error.log has the following:
2019/08/30 12:54:33 [emerg] 26171#26171: "root" directive is duplicate in /etc/nginx/vhosts/www-root/MYSITE.conf:169

In the specified file, I did not see duplicates of the root directive; include files don't have it at all. Moreover, 169 lines of code are not in this file either (168 lines in total).
When I first rolled out the site, the letsencrypt certificate got up without any problems. Since then, the server config has not changed.
Google, unfortunately, is silent, and in which direction I should dig is also not clear.
config files:
/etc/nginx/nginx.conf

user www-data;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/vhosts/*/*.conf;
  client_max_body_size 128m;
  server {
    server_name localhost;
  disable_symlinks if_not_owner;
  listen 80;
  listen [::]:80;
  include /etc/nginx/vhosts-includes/*.conf;
  location @fallback {
    error_log /dev/null crit;
    proxy_pass http://127.0.0.1:8080;
    proxy_redirect http://127.0.0.1:8080 /;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    access_log off ;
  }
  }
}


/etc/nginx/vhosts/www-root/MYSITE.conf

server {
    client_max_body_size 1000M;
    client_body_buffer_size 1000M;
    fastcgi_read_timeout 6000;

    listen АЙПИ_АДРЕС:80;
    listen АЙПИ_АДРЕС:443 ssl;

    ssl_certificate "/var/www/httpd-cert/www-root/MYSITE_le2.crtca";
  ssl_certificate_key "/var/www/httpd-cert/www-root/MYSITE_le2.key";
  ssl_ciphers EECDH:+AES256:-3DES:RSA+AES:!NULL:!RC4;
  ssl_prefer_server_ciphers on;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_dhparam /etc/ssl/certs/dhparam4096.pem;
  
  access_log /var/www/httpd-logs/MYSITE.access.log;
  error_log /var/www/httpd-logs/MYSITE.error.log notice;

    charset UTF-8;

    server_name MYSITE www.MYSITE;

    root /var/www/www-root/data/www/MYSITE;
    index index.php;

    try_files $uri $uri/ /index.php?$query_string;
    
    location ^~ /.well-known/acme-challenge/ {
        allow all;
        default_type "text/plain";
    }

    location /index.php {
        include /etc/nginx/fastcgi_params;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@MYSITE";
        fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
    }

    # for install only
    location /install.php {
        include /etc/nginx/fastcgi_params;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@MYSITE";
        fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
    }

    location /api.php {
        fastcgi_split_path_info  ^(.+\.php)(.*)$;
        include /etc/nginx/fastcgi_params;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@MYSITE";
        fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
    }
    
    location ~ /(oauth.php|link.php|payments.php) {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ^~ /wa-data/protected/ {
        internal;
    }

    location ~ /wa-content {
        allow all;
    }

    location ^~ /(wa-apps|wa-plugins|wa-system|wa-widgets)/.*/(lib|locale|templates)/ {
        deny all;
    }

    location ~* ^/wa-(cache|config|installer|log|system)/ {
        return 403;
    }

    location ~* ^/wa-data/public/contacts/photos/[0-9]+/ {
         # единственное место, где есть еще одно ипоминание root, но оно закомментированно
         # root /var/www/www-root/data/www/MYSITE/;
         access_log off;
         expires  30d;
         error_page   404  =  @contacts_thumb;
    }

    location @contacts_thumb {
        include /etc/nginx/fastcgi_params;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@MYSITE";
        fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        fastcgi_param  SCRIPT_NAME  /wa-data/public/contacts/photos/thumb.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root/wa-data/public/contacts/photos/thumb.php;
    }

    # photos app
    location ~* ^/wa-data/public/photos/[0-9]+/ {
        access_log   off;
        expires      30d;
        error_page   404  =  @photos_thumb;
    }

    location @photos_thumb {
        include /etc/nginx/fastcgi_params;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@MYSITE";
        fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        fastcgi_param  SCRIPT_NAME  /wa-data/public/photos/thumb.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root/wa-data/public/photos/thumb.php;
    }
    # end photos app

    # shop app
    location ~* ^/wa-data/public/shop/products/[0-9]+/ {
        access_log   off;
        expires      30d;
        error_page   404  =  @shop_thumb;
    }
    location @shop_thumb {
        include /etc/nginx/fastcgi_params;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@MYSITE";
        fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        fastcgi_param  SCRIPT_NAME  /wa-data/public/shop/products/thumb.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root/wa-data/public/shop/products/thumb.php;
    }

    location ~* ^/wa-data/public/shop/promos/[0-9]+ {
        access_log   off;
        expires      30d;
        error_page   404  =  @shop_promo;
    }
    location @shop_promo {
        include /etc/nginx/fastcgi_params;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@MYSITE";
        fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        fastcgi_param  SCRIPT_NAME  /wa-data/public/shop/promos/thumb.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root/wa-data/public/shop/promos/thumb.php;
    }
    # end shop app

    # mailer app
    location ~* ^/wa-data/public/mailer/files/[0-9]+/ {
        access_log   off;
        error_page   404  =  @mailer_file;
    }
    location @mailer_file {
        include /etc/nginx/fastcgi_params;
        fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f webmaster@MYSITE";
        fastcgi_pass unix:/var/www/php-fpm/www-root.sock;
        fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
        fastcgi_param  SCRIPT_NAME  /wa-data/public/mailer/files/file.php;
        fastcgi_param  SCRIPT_FILENAME $document_root/wa-data/public/mailer/files/file.php;
    }
    # end mailer app

    location ~* ^.+\.(jpg|jpeg|gif|png|js|css)$ {
        access_log   off;
        expires      30d;
    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuzin, 2019-08-30
@Bobson8

What is in this /etc/nginx/nginx.conf file? how many rows is that in 169?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question