Xenforo 2 Nginx rewrites Error

Itworx4me

Well-known member
I have been trying to get this to work on my test server and it won't work.
I get this error:
nginx: [emerg] "location" directive is not allowed here in /usr/local/nginx/conf/conf.d/domain.com.conf:70
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

Here are my rewrites:
Code:
location / {
    try_files $uri $uri/ /index.php?$uri&$args;
    index index.php index.html;
}

location /install/data/ {
    internal;
}
location /install/templates/ {
    internal;
}
location /internal_data/ {
    internal;
}
location /library/ { #legacy
    internal;
}
location /src/ {
    internal;
}

location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include         fastcgi_params;
}

Any help would be much appreciated.

Thanks,
Iworx4me
 
What does line 70 correspond to in the config file?

It's likely there's an erroneous bracket somewhere.

Liam
 
What does line 70 correspond to in the config file?

It's likely there's an erroneous bracket somewhere.

Liam
Its the start of the location
Code:
location / {
    try_files $uri $uri/ /index.php?$uri&$args;
    index index.php index.html;
}

Thanks for the help
Itworx4me
 
I added it to the end of the domain.com.conf file

Code:
 include /usr/local/nginx/conf/staticfiles.conf;
  include /usr/local/nginx/conf/php.conf;
  include /usr/local/nginx/conf/drop.conf;
  #include /usr/local/nginx/conf/errorpage.conf;
  include /usr/local/nginx/conf/vts_server.conf;

}

location / {
    try_files $uri $uri/ /index.php?$uri&$args;
    index index.php index.html;
}

location /install/data/ {
    internal;
    allow 127.0.0.1;
    allow .........
    deny all;
}

location /install/templates/ {
    internal;
    allow 127.0.0.1;
    allow .........
    deny all;
}
 
Actually, is that the full contents of your config file? If so you have an extra curly brace after your includes that probably shouldn't be there
 
Here is my domain.com.conf file
Code:
# Centmin Mod Getting Started Guide
# must read http://centminmod.com/getstarted.html

# redirect from non-www to www
# uncomment, save file and restart Nginx to enable
# if unsure use return 302 before using return 301
#server {
#            listen   80;
#            server_name Domain.com;
#            return 301 $scheme://www.Domain.com$request_uri;
#       }

server {

  server_name Domain.com www.Domain.com;

# ngx_pagespeed & ngx_pagespeed handler
#include /usr/local/nginx/conf/pagespeed.conf;
#include /usr/local/nginx/conf/pagespeedhandler.conf;
#include /usr/local/nginx/conf/pagespeedstatslog.conf;

  #add_header X-Content-Type-Options "nosniff" always;
  #add_header X-Xss-Protection "1; mode=block" always;
  #add_header X-Content-Type-Options "nosniff" always;

  # limit_conn limit_per_ip 16;
  # ssi  on;

  access_log /home/nginx/domains/Domain.com/log/access.log main_ext buffer=256k flush=60m;
  error_log /home/nginx/domains/Domain.com/log/error.log;

  include /usr/local/nginx/conf/autoprotect/Domain.com/autoprotect-Domain.com.conf;
  root /home/nginx/domains/Domain.com/public;
  # uncomment cloudflare.conf include if using cloudflare for
  # server and/or vhost site
  #include /usr/local/nginx/conf/cloudflare.conf;
  include /usr/local/nginx/conf/503include-main.conf;

  # prevent access to ./directories and files
  #location ~ (?:^|/)\. {
  # deny all;
  #}

  location / {
    try_files $uri $uri/ /index.php?$uri&$args;
    index index.php index.html;
  }

  location /install/data/ {
    internal;
    allow 127.0.0.1;
    allow 0.0.0.0.0.0
    deny all;
  }

  location /install/templates/ {
    internal;
    allow 127.0.0.1;
    allow 0.0.0.0.0
    deny all;
  }

  location /internal_data/ {
    internal;
    allow 127.0.0.1;
    allow 0.0.0.0.0
    deny all;
  }

  location /src/ {
    internal;
    allow 127.0.0.1;
    allow 0.0.0.0.0
    deny all;
  }

  location ~ \.php$ {
    try_files $uri =404;
    fastcgi_pass    127.0.0.1:9000;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include         fastcgi_params;
  }

  location / {
  include /usr/local/nginx/conf/503include-only.conf;

# block common exploits, sql injections etc
#include /usr/local/nginx/conf/block.conf;

  # Enables directory listings when index file not found
  #autoindex  on;

  # Shows file listing times as local time
  #autoindex_localtime on;

  # Enable for vBulletin usage WITHOUT vbSEO installed
  # More example Nginx vhost configurations at
  # http://centminmod.com/nginx_configure.html
  #try_files            $uri $uri/ /index.php;

  }

  include /usr/local/nginx/conf/staticfiles.conf;
  include /usr/local/nginx/conf/php.conf;
  include /usr/local/nginx/conf/drop.conf;
  #include /usr/local/nginx/conf/errorpage.conf;
  include /usr/local/nginx/conf/vts_server.conf;
 }

Any help would be much appreciated
Itworx4me
 
Last edited:
You have a duplicate / location

Code:
  location / {
include /usr/local/nginx/conf/503include-only.conf;

# block common exploits, sql injections etc
#include /usr/local/nginx/conf/block.conf;

# Enables directory listings when index file not found
#autoindex  on;

# Shows file listing times as local time
#autoindex_localtime on;

# Enable for vBulletin usage WITHOUT vbSEO installed
# More example Nginx vhost configurations at
# http://centminmod.com/nginx_configure.html
#try_files            $uri $uri/ /index.php;

}
 
Top Bottom