1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

duplicate location "/" - nginx

Discussion in 'Nginx' started by TheVisitors, Jul 3, 2014.

  1. #1
    Ironically, it's the small things that get me puzzled and this one is driving me a little nuts. lol

    I changed the site from /forums/ to simple / and you would think it would be as simple as removing that "forums" entry from the config. It after all seems straight forward and is exactly how it would be done on apache, but obviously, nginx is of another nature.

    The original config
    
    server {
          listen 80; # listen for IPv4
          listen [::]:80; # listen for IPv6
            server_name  www.sociallyuncensored.eu;
        return 301 $scheme://sociallyuncensored.eu$request_uri;
    }
    
    server {
          listen 80; # listen for IPv4
          listen [::]:80; # listen for IPv6
          server_name  sociallyuncensored.eu;
    
          access_log  /var/log/nginx/log/sociallyuncensored.eu.log  main;
        error_log /var/log/nginx/log/sociallyuncensored.eu.error.log;
    
          root   /usr/share/nginx/sociallyuncensored.eu/public_html;
    
        include /etc/nginx/rewrites.conf;
    
        location /forums/ {
                    index index.php index.html index.htm;
                    try_files $uri $uri/ /index.php?$uri&$args;
                    location /forums/internal_data {
                            location ~ \.(data|html|php)$ {
                                    internal;
                            }
                            internal;
                    }
                    location /forums/library {
                            location ~ \.(default|html|php|txt|xml)$ {
                                    internal;
                            }
                            internal;
                    }
            }
    
            location /forums/admin.php {
            auth_basic "Private";
            auth_basic_user_file /usr/share/nginx/htpasswd;
        include /etc/nginx/php.conf;
            }
    
            location /forums/install/ {
        index index.php index.html index.htm;
            auth_basic "Private";
            auth_basic_user_file /usr/share/nginx/htpasswd;
            include /etc/nginx/php.conf;
            }
    
            include /etc/nginx/php.conf;
            include /etc/nginx/staticfiles.conf;
    }
    
    PHP:
    The new config
    
    server {
          listen 80; # listen for IPv4
          listen [::]:80; # listen for IPv6
            server_name  www.sociallyuncensored.eu;
        return 301 $scheme://sociallyuncensored.eu$request_uri;
    }
    
    server {
          listen 80; # listen for IPv4
          listen [::]:80; # listen for IPv6
          server_name  sociallyuncensored.eu;
    
          access_log  /var/log/nginx/log/sociallyuncensored.eu.log  main;
        error_log /var/log/nginx/log/sociallyuncensored.eu.error.log;
    
          root   /usr/share/nginx/sociallyuncensored.eu/public_html;
    
        include /etc/nginx/rewrites.conf;
    
        location / {
                    index index.php index.html index.htm;
                    try_files $uri $uri/ /index.php?$uri&$args;
                    location /internal_data {
                            location ~ \.(data|html|php)$ {
                                    internal;
                            }
                            internal;
                    }
                    location /library {
                            location ~ \.(default|html|php|txt|xml)$ {
                                    internal;
                            }
                            internal;
                    }
            }
    
            location /admin.php {
            auth_basic "Private";
            auth_basic_user_file /usr/share/nginx/htpasswd;
        include /etc/nginx/php.conf;
            }
    
            location /install/ {
        index index.php index.html index.htm;
            auth_basic "Private";
            auth_basic_user_file /usr/share/nginx/htpasswd;
            include /etc/nginx/php.conf;
            }
    
            include /etc/nginx/php.conf;
            include /etc/nginx/staticfiles.conf;
    }
    
    PHP:
    As you can see all I did was remove /forums/ because the site is now located in the document root. This seems like a no brainer and yet I continue to receive this simple error.

    nginx: [emerg] duplicate location "/" in /etc/nginx/conf.d/sociallyuncensored_eu.conf:20
    nginx: configuration file /etc/nginx/nginx.conf test failed
    PHP:
    Solutions?
     
    TheVisitors, Jul 3, 2014 IP
  2. TheVisitors

    TheVisitors Greenhorn

    Messages:
    72
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    18
    #2
    Solution was found else where; http://www.webhostingtalk.com/showthread.php?t=1390596
     
    TheVisitors, Jul 4, 2014 IP