Join the community today
Become a Member

Centmin Mod .09 + Flarum

Discussion in 'Forum software usage' started by Peace-Keeper, Nov 6, 2015.

  1. Peace-Keeper

    Peace-Keeper Member

    46
    8
    8
    Jul 9, 2014
    Ratings:
    +11
    Local Time:
    11:27 PM
    Mainline
    10.1
    Starting nginx: nginx: [emerg] "location" directive is not allowed here in /usr/local/nginx/conf/staticfiles.conf:3

    Line 3 happens to be

    PHP:
        # prepare for letsencrypt 
        # https://community.centminmod.com/posts/17774/
        
    location ~ /.well-known {
            
    location ~ /.well-known/acme-challenge/(.*) {
                
    more_set_headers    "Content-Type: text/plain";
            }
        }
    I get this error anytime I try to edit my vhost config file.
    Installation
     
    • Informative Informative x 1
  2. eva2000

    eva2000 Administrator Staff Member

    29,031
    6,589
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,782
    Local Time:
    1:27 PM
    Nginx 1.13.x
    MariaDB 5.5
    what does your full nginx vhost domain conf look like ? possibly missing a curly brace in your vhost so it included the staticfiles.conf include in it's location ?
     
    Last edited: Nov 6, 2015
  3. Peace-Keeper

    Peace-Keeper Member

    46
    8
    8
    Jul 9, 2014
    Ratings:
    +11
    Local Time:
    11:27 PM
    Mainline
    10.1
    Final result is the last code box ;)

    Well the stock one provided (that was generated by Centmin Mod) was this

    PHP:
    # 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 bannedfromtaz.com;
    #            return 301 $scheme://www.bannedfromtaz.com$request_uri;
    #       }

    server {
      
    server_name bannedfromtaz.com www.bannedfromtaz.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/bannedfromtaz.com/log/access.log combined buffer=256k flush=60m;
      
    error_log /home/nginx/domains/bannedfromtaz.com/log/error.log;

      
    root /home/nginx/domains/bannedfromtaz.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;
    }
    I simple amended by replacing line 34 with this as told by Flarum here ( Installation )

    PHP:
        location / { try_files $uri $uri/ /index.php?$query_string; }
        
    location /api try_files $uri $uri/ /api.php?$query_string; }
        
    location /admin try_files $uri $uri/ /admin.php?$query_string; }

        
    location /flarum {
            
    deny all;
            return 
    404;
        }

        
    location ~ .php$ {
            
    fastcgi_split_path_info ^(.+.php)(/.+)$;
            
    fastcgi_pass unix:/var/run/php5-fpm.sock;
            
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            
    fastcgi_index index.php;
            include 
    fastcgi_params;
        }
      
        
    location ~* \.html$ {
            
    expires -1;
        }

        
    location ~* \.(css|js|gif|jpe?g|png)$ {
            
    expires 1M;
            
    add_header Pragma public;
            
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        }

        
    gzip on;
        
    gzip_http_version 1.1;
        
    gzip_vary on;
        
    gzip_comp_level 6;
        
    gzip_proxied any;
        
    gzip_types application/atom+xml \
                   
    application/javascript \
                   
    application/json \
                   
    application/vnd.ms-fontobject \
                   
    application/x-font-ttf \
                   
    application/x-web-app-manifest+json \
                   
    application/xhtml+xml \
                   
    application/xml \
                   
    font/opentype \
                   
    image/svg+xml \
                   
    image/x-icon \
                   
    text/css \
                   
    text/html \
                   
    text/plain \
                   
    text/xml;
        
    gzip_buffers 16 8k;
        
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";
    The end result was this :)

    PHP:
    # 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 bannedfromtaz.com;
    #            return 301 $scheme://www.bannedfromtaz.com$request_uri;
    #       }

    server {
      
    server_name bannedfromtaz.com www.bannedfromtaz.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/bannedfromtaz.com/log/access.log combined buffer=256k flush=60m;
      
    error_log /home/nginx/domains/bannedfromtaz.com/log/error.log;

      
    root /home/nginx/domains/bannedfromtaz.com/public;

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

        
    location / { try_files $uri $uri/ /index.php?$query_string; }
        
    location /api try_files $uri $uri/ /api.php?$query_string; }
        
    location /admin try_files $uri $uri/ /admin.php?$query_string; }

        
    location /flarum {
            
    deny all;
            return 
    404;
        }

        
    location ~ .php$ {
            
    fastcgi_split_path_info ^(.+.php)(/.+)$;
            
    fastcgi_pass unix:/var/run/php5-fpm.sock;
            
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            
    fastcgi_index index.php;
            include 
    fastcgi_params;
        }
      
        
    location ~* \.html$ {
            
    expires -1;
        }

        
    location ~* \.(css|js|gif|jpe?g|png)$ {
            
    expires 1M;
            
    add_header Pragma public;
            
    add_header Cache-Control "public, must-revalidate, proxy-revalidate";
        }

        
    gzip on;
        
    gzip_http_version 1.1;
        
    gzip_vary on;
        
    gzip_comp_level 6;
        
    gzip_proxied any;
        
    gzip_types application/atom+xml \
                   
    application/javascript \
                   
    application/json \
                   
    application/vnd.ms-fontobject \
                   
    application/x-font-ttf \
                   
    application/x-web-app-manifest+json \
                   
    application/xhtml+xml \
                   
    application/xml \
                   
    font/opentype \
                   
    image/svg+xml \
                   
    image/x-icon \
                   
    text/css \
                   
    text/html \
                   
    text/plain \
                   
    text/xml;
        
    gzip_buffers 16 8k;
        
    gzip_disable "MSIE [1-6]\.(?!.*SV1)";

    # 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;
    }
     
  4. eva2000

    eva2000 Administrator Staff Member

    29,031
    6,589
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,782
    Local Time:
    1:27 PM
    Nginx 1.13.x
    MariaDB 5.5
    @Peace-Keeper you don't need php locations as php.conf include file takes care of it all so you can do just

    don't need all gzip stuff too as that is done out of box server wide

    also you had a broken location from the default location / {} out of box stuff you can remove

    don't need prevent ./ directories too as include file drop.conf has all security done

    don't need html and image locations as staticfiles.conf include takes care of it all

    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 bannedfromtaz.com;
    #            return 301 $scheme://www.bannedfromtaz.com$request_uri;
    #       }
    
    server {
      server_name bannedfromtaz.com www.bannedfromtaz.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/bannedfromtaz.com/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/bannedfromtaz.com/log/error.log;
    
      root /home/nginx/domains/bannedfromtaz.com/public;
    
        location / { try_files $uri $uri/ /index.php?$query_string; }
        location /api { try_files $uri $uri/ /api.php?$query_string; }
        location /admin { try_files $uri $uri/ /admin.php?$query_string; }
    
        location /flarum {
            deny all;
            return 404;
        }
    
      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;
    }
     
    • Winner Winner x 1
  5. Peace-Keeper

    Peace-Keeper Member

    46
    8
    8
    Jul 9, 2014
    Ratings:
    +11
    Local Time:
    11:27 PM
    Mainline
    10.1
    @eva2000 So they basically instructed me to add a lot of stuff I didn't need or that you had thought of ahead and included in Centmin Mod's configuration? Huh...

    I guess there is only 1 question....

    Where is the donate button? :D
     
  6. eva2000

    eva2000 Administrator Staff Member

    29,031
    6,589
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,782
    Local Time:
    1:27 PM
    Nginx 1.13.x
    MariaDB 5.5
    Centmin Mod Nginx tries to be smarter out of the box so config vhost files aren't as messy and can be applied to many nginx vhosts. Some folks may have trickier configurations, so you can also try making a copy of the default include files like php.conf and making on specific site changes and just change to that copied include file instead of defaults if need be :)

     
    • Like Like x 1