Learn about Centmin Mod LEMP Stack today
Become a Member

Xenforo Xenforo problem

Discussion in 'Forum software usage' started by DaB, Aug 10, 2016.

  1. DaB

    DaB Member

    45
    5
    8
    Aug 10, 2016
    Ratings:
    +6
    Local Time:
    10:56 AM
    Current
    Current
    I have edited the /usr/local/nginx/conf/conf.d/mydomain.com.conf file so I can enable friendly URLS.

    When I restart nginx, I get this error.

    Restarting nginx (via systemctl): Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.


    Any ideas?

    TIA.
     
  2. eva2000

    eva2000 Administrator Staff Member

    55,417
    12,256
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,837
    Local Time:
    7:56 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  3. DaB

    DaB Member

    45
    5
    8
    Aug 10, 2016
    Ratings:
    +6
    Local Time:
    10:56 AM
    Current
    Current
    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 mydomain.com;
    #            return 301 $scheme://www.mydomain.com$request_uri;
    #       }
    
    server {
      server_name mydomain.com www.mydomain.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;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/therailwaymen.com/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/mydomain.com/log/error.log;
    
      root /home/nginx/domains/mydomain.com/public;
    
      # prevent access to ./directories and files
      location ~ (?:^|/)\. {
       deny all;
      }
    
      location / {
    
    # 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;
    }
    
    location / {
                index index.php index.html index.htm;
                try_files $uri $uri/ /index.php?$uri&$args;
    
            }
    
            location /internal_data/ {
            internal;
            allow 127.0.0.1;
            allow 111.222.333.444;
            deny all;
            }
    
            location /library/ {
            internal;
            allow 127.0.0.1;
            allow 111.222.333.444;
            deny all;
            }
    
     
    Last edited: Aug 10, 2016
  4. eva2000

    eva2000 Administrator Staff Member

    55,417
    12,256
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,837
    Local Time:
    7:56 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  5. eva2000

    eva2000 Administrator Staff Member

    55,417
    12,256
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,837
    Local Time:
    7:56 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    also type output for
    Code (Text):
    nginx -t
     
  6. DaB

    DaB Member

    45
    5
    8
    Aug 10, 2016
    Ratings:
    +6
    Local Time:
    10:56 AM
    Current
    Current
    Code:
    nginx: [emerg] "location" directive is not allowed here in /usr/local/nginx/conf/conf.d/mydomain.com.conf:59
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
     
  7. eva2000

    eva2000 Administrator Staff Member

    55,417
    12,256
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,837
    Local Time:
    7:56 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yup because you placed the xenforo rules outside of server{} context

    correct one would be below notice the placement
    Code (Text):
    # 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 therailwaymen.com;
    #            return 301 $scheme://www.mydomain.com$request_uri;
    #       }
    
    server {
      server_name mydomain.com www.mydomain.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;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/therailwaymen.com/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/mydomain.com/log/error.log;
    
      root /home/nginx/domains/mydomain.com/public;
    
    location / {
                index index.php index.html index.htm;
                try_files $uri $uri/ /index.php?$uri&$args;
    
            }
    
            location /internal_data/ {
            internal;
            allow 127.0.0.1;
            allow 111.222.333.444;
            deny all;
            }
    
            location /library/ {
            internal;
            allow 127.0.0.1;
            allow 111.222.333.444;
            deny all;
            }
    
      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;
    }
    
    

    also read Nginx Rewrites for Xenforo Friendly Urls - CentminMod.com LEMP Nginx web stack for CentOS for password protecting admin.php