nginx: [emerg] duplicate location "/"

Tigl

Verified User
Joined
Dec 4, 2015
Messages
5
Hi, I have a DirectAdmin server with NGNIX. After a few restores I get the following error:

Code:
root@cloud:~# service nginx restart 
nginx: [emerg] duplicate location "/" in /usr/local/directadmin/data/users/mojo/nginx.conf:63
nginx: configuration file /etc/nginx/nginx.conf test failed
/etc/init.d/nginx: line 78: return: can only `return' from a function or sourced script
Shutting down nginx: 
Starting nginx: nginx: [emerg] duplicate location "/" in /usr/local/directadmin/data/users/mojo/nginx.conf:63

Where nginx.conf says:
Code:
# Auto generated nginx config file by DirectAdmin version 1.49.1
# Modifying this file is not recommended as any changes you make will be
# overwritten when the user makes any changes to his/her website

# For global config changes that affect all Users, see this guide:
# http://help.directadmin.com/item.php?id=558
# For local config changes that only affect one User, see this guide:
# http://help.directadmin.com/item.php?id=3


server
{
	listen 37.97.132.134:80;
	server_name mojo.nl www.mojo.nl ;
	access_log /var/log/nginx/domains/mojo.nl.log;
	access_log /var/log/nginx/domains/mojo.nl.bytes bytes;
	error_log /var/log/nginx/domains/mojo.nl.error.log;
	root /home/mojo/domains/mojo.nl/public_html;
	index index.php index.html index.htm;
	include /usr/local/directadmin/data/users/mojo/nginx_php.conf;
	include /etc/nginx/webapps.conf;
       location /
       {
               rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
               if (!-e $request_filename) {
                       rewrite  ^(.+)$  /index.php?q=$1  last;
               }
       }
}

server
{
	listen 37.97.132.134:443 ssl;
	server_name mojo.nl www.mojo.nl ;
	access_log /var/log/nginx/domains/mojo.nl.log;
	access_log /var/log/nginx/domains/mojo.nl.bytes bytes;
	error_log /var/log/nginx/domains/mojo.nl.error.log;
	root /home/mojo/domains/mojo.nl/private_html;
	index index.php index.html index.htm;
	ssl on;
	ssl_certificate /etc/nginx/ssl.crt/server.crt.combined;
	ssl_certificate_key /etc/nginx/ssl.key/server.key;
	include /usr/local/directadmin/data/users/mojo/nginx_php.conf;
	include /etc/nginx/webapps.ssl.conf;
}

server
{
	listen 37.97.132.134:80;
	server_name ticketsenconcertkaarten.nl www.ticketsenconcertkaarten.nl ;
	access_log /var/log/nginx/domains/ticketsenconcertkaarten.nl.log;
	access_log /var/log/nginx/domains/ticketsenconcertkaarten.nl.bytes bytes;
	error_log /var/log/nginx/domains/ticketsenconcertkaarten.nl.error.log;
	root /home/mojo/domains/ticketsenconcertkaarten.nl/public_html;
	index index.php index.html index.htm;
	include /usr/local/directadmin/data/users/mojo/nginx_php.conf;
	location /
	{
		rewrite ^/.*$ http://weetwaarjekoopt.nl permanent;
	}
	include /etc/nginx/webapps.conf;
       location /
       {
               rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
               if (!-e $request_filename) {
                       rewrite  ^(.+)$  /index.php?q=$1  last;
               }
       }
}


To be honest I have no clue what I am doing or how I can fix this. Can someone please help me?
 
It has got something to do with that wp-includes rewrite. I assume this is a webserver=nginx setup, I haven't used that personally and I'm not sure how those rewrite lines get in there; but the times that I saw that kind of stuff it often went wrong and I find it odd that application rewrite rules are in the webserver config on a shared hosting setup; but that's just my 2 cents.
 
Found the problem;


Code:
location /
       {
               rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;
               if (!-e $request_filename) {
                       rewrite  ^(.+)$  /index.php?q=$1  last;
               }
       }
       
       # force permalinks wp
if (!-e $request_filename) {
  rewrite ^.*$ /index.php last;
}

Was in the ngnix.conf. Deleted it and added it to the users config, works like a charm again! Thanks for your help.
 
Back
Top