Banzai
By:
Banzai

Nginx config error: [emerg] 1226#0: duplicate location

April 19, 2015 4.7k views
Nginx Logging Configuration Management Server Optimization Ubuntu

I've been getting web socket errors in the browser console so I added to my site's Nginx config file, some code a fellow posted here: http://stackoverflow.com/questions/17014969/meteor-websocket-handshake-error...
But Nginx did not approve. The site isn't responding in the browser and it says "fail" when I try to restart the Nginx service after removing the new code from the config file. There's this error in /var/log/nginx/error.log:

2015/04/18 21:09:57 [emerg] 1226#0: duplicate location "/" in /etc/nginx/conf.d/loyr.conf:14

And this is the Nginx config file for the domain /etc/nginx/conf.d/loyr.conf:

server {
 listen 80;

 server_name loyr.co;

 location / {
 proxy_pass http://localhost:3001;
 proxy_http_version 1.1;
 proxy_set_header Upgrade $http_upgrade;
 proxy_set_header Connection ‘upgrade’;
 proxy_set_header Host $host;
 proxy_cache_bypass $http_upgrade;
 }

}

Any ideas? Thanks!

5 comments
  • The proxy_set_header Connection line using curly quotes, not sure if it is the cause of the problem but try changing it to normal quotes.

    server {
     listen 80;
    
     server_name loyr.co;
    
     location / {
     proxy_pass http://localhost:3001;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection 'upgrade';
     proxy_set_header Host $host;
     proxy_cache_bypass $http_upgrade;
     }
    
    }
    
  • Didn't seem to work.

  • How many other virtual hosts do you have on this Droplet? Please post the complete virtual host file of loyr.co on pastebin.com and share its URL.

  • Hello Jesin,
    I am having this issue as well on ubuntu 14.04 server. I have 5 domains on one ip address. I setup nginx to manage the frontend and apache to handle the back-end and the site I want to run magento on has ssl (https://www.diasporagroceries.com). below are some lines i get in nginx error logs...

    =============================================
    016/01/22 01:17:52 [warn] 20173#0: conflicting server name "www.cronusweb.com" on [::]:80, ignored
    2016/01/22 01:17:52 [warn] 20173#0: conflicting server name "cronusweb.com" on 0.0.0.0:443, ignored
    2016/01/22 01:17:52 [warn] 20173#0: conflicting server name "www.cronusweb.com" on 0.0.0.0:443, ignored
    2016/01/22 01:27:57 [warn] 20335#0: conflicting server name "diasporagrocery.com" on 0.0.0.0:80, ignored
    2016/01/22 01:27:57 [warn] 20335#0: conflicting server name "diasporagrocery.com" on [::]:80, ignored
    2016/01/22 01:27:58 [warn] 20339#0: conflicting server name "diasporagrocery.com" on 0.0.0.0:80, ignored
    2016/01/22 01:27:58 [warn] 20339#0: conflicting server name "diasporagrocery.com" on [::]:80, ignored
    2016/01/22 01:29:08 [emerg] 20370#0: unknown "www" variable
    2016/01/22 01:29:43 [warn] 20396#0: conflicting server name "diasporagrocery.com" on 0.0.0.0:80, ignored
    2016/01/22 01:29:43 [warn] 20396#0: conflicting server name "diasporagrocery.com" on [::]:80, ignored
    2016/01/22 01:29:44 [warn] 20400#0: conflicting server name "diasporagrocery.com" on 0.0.0.0:80, ignored
    2016/01/22 01:29:44 [warn] 20400#0: conflicting server name "diasporagrocery.com" on [::]:80, ignored
    2016/01/22 05:50:43 [error] 20402#0: *146 FastCGI sent in stderr: "PHP message: PHP Warning: require(/var/www/diasporagroceries.com/publichtml/vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php): failed to $
    PHP message: PHP Fatal error: require(): Failed opening required '/var/www/diasporagroceries.com/public
    html/vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php' (includepath='/var/www/diasporagroceries.com/$
    2016/01/22 05:52:13 [error] 20402#0: *148 FastCGI sent in stderr: "PHP message: PHP Warning: require(/var/www/diasporagroceries.com/public
    html/vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php): failed to $
    PHP message: PHP Fatal error: require(): Failed opening required '/var/www/diasporagroceries.com/publichtml/vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php' (includepath='/var/www/diasporagroceries.com/$
    2016/01/22 07:23:41 [error] 20402#0: *180 directory index of "/var/www/diasporagrocery.com/publichtml/" is forbidden, client: 66.249.66.88, server: www.diasporagrocery.com, request: "GET / HTTP/1.1", host: "www$
    2016/01/22 08:44:28 [error] 20402#0: *196 FastCGI sent in stderr: "PHP message: PHP Fatal error: Class 'Zend\Code\Generator\DocBlock\Tag\GenericTag' not found in /var/www/diasporagroceries.com/public
    html/vendo$
    2016/01/22 08:45:43 [error] 20402#0: *198 FastCGI sent in stderr: "PHP message: PHP Fatal error: Class 'Zend\Code\Generator\DocBlock\Tag\GenericTag' not found in /var/www/diasporagroceries.com/publichtml/vendo$
    2016/01/22 13:57:43 [error] 20402#0: *298 directory index of "/var/www/diasporagrocery.com/public
    html/" is forbidden, client: 52.26.235.13, server: www.diasporagrocery.com, request: "GET / HTTP/1.1", host: "www$
    2016/01/22 15:51:43 [error] 20402#0: *486 directory index of "/var/www/diasporagrocery.com/publichtml/" is forbidden, client: 66.249.66.91, server: www.diasporagrocery.com, request: "GET / HTTP/1.1", host: "www$
    2016/01/22 16:15:08 [warn] 31597#0: conflicting server name "diasporagrocery.com" on 0.0.0.0:80, ignored
    2016/01/22 16:15:08 [warn] 31597#0: conflicting server name "diasporagrocery.com" on [::]:80, ignored
    2016/01/22 16:15:09 [warn] 31601#0: conflicting server name "diasporagrocery.com" on 0.0.0.0:80, ignored
    2016/01/22 16:15:09 [warn] 31601#0: conflicting server name "diasporagrocery.com" on [::]:80, ignored
    2016/01/22 16:35:38 [error] 31907#0: *14 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 91.121.154.206, server: www.diasporagroceries.com, request: "GET /ma$
    2016/01/22 16:53:13 [error] 31907#0: *47 directory index of "/var/www/diasporagrocery.com/public
    html/" is forbidden, client: 66.249.66.95, server: www.diasporagrocery.com, request: "GET / HTTP/1.1", host: "www.$
    2016/01/22 17:07:19 [emerg] 32565#0: duplicate location "/" in /etc/nginx/sites-enabled/diasporagroceries.com:47
    2016/01/22 18:01:03 [error] 32686#0: *103 directory index of "/var/www/diasporagrocery.com/public_html/" is forbidden, client: 66.249.66.95, server: www.diasporagrocery.com, request: "GET / HTTP/1.1", host: "www$

    ====================================================

    WHats your advice on how to set this up with an ip that has many domains setup using nginx front end and apache backend with ssl.

    Your advice would be so appreciated.

  • Hi @temiamosu,

    Sorry I'm late but if you're still having this issue try the following.

    The sites-enabled Nginx directory could be having some duplicate files due to improperly closed file editors.

    Find such files and remove them.

    ls -al /etc/nginx/sites-enabled
    

    As for the PHP errors I think you're missing a module.

Be the first one to answer this question.