Welcome to Centmin Mod Community
Register Now

vBulletin [Help] Mod-Rewrite in Nginx

Discussion in 'Forum software usage' started by computer19852007, Jun 25, 2014.

Tags:
  1. computer19852007

    computer19852007 Member

    84
    8
    8
    Jun 25, 2014
    Ratings:
    +9
    Local Time:
    9:04 AM
    Centmin Mod 1.2.3-eva2000.06
    MariaDB 5.5.34
    i have read this topic http://centminmod.com/nginx_configure_vbulletin4_friendly_urls.html

    I have used Vbulletin Suite 4.2.2 P1 (forum and CMS)


    and i have config in this tip, but it not working in CMS when i add new content and this show error "404 Not Found"

    my forum link mark: content/1-home/addcontent => "404 Not Found"

    Please Help me.

    Thanks
     
    Last edited: Jun 25, 2014
  2. eva2000

    eva2000 Administrator Staff Member

    54,384
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    12:04 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    post your entire contents for your domain's Nginx vhost file at /usr/local/nginx/conf/conf.d/yourdomain.com.conf
     
  3. computer19852007

    computer19852007 Member

    84
    8
    8
    Jun 25, 2014
    Ratings:
    +9
    Local Time:
    9:04 AM
    Centmin Mod 1.2.3-eva2000.06
    MariaDB 5.5.34
    @eva2000

    Code:
    server {
        listen       80;
        server_name diendantinhoc.vn;
        return       301 http://www.diendantinhoc.vn$request_uri;
    }
    
    server {
      server_name www.diendantinhoc.vn;
    
    
    
    # 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/diendantinhoc.vn/log/access.log combined buffer=32k;
      error_log /home/nginx/domains/diendantinhoc.vn/log/error.log;
    
      root /home/nginx/domains/diendantinhoc.vn/public;
    
      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
      #try_files         / /index.php;
    
    try_files $uri $uri/ @rewrite;
    }
    
            location /includes {
            allow 127.0.0.1;
            deny all;
            }
    
            location /packages {
            allow 127.0.0.1;
            deny all;
            }
    
            location /vb {
            allow 127.0.0.1;
            deny all;
            }
    
            location /admincp {
            include /usr/local/nginx/conf/php.conf;
            #auth_basic "Private";
            #auth_basic_user_file /usr/local/nginx/conf/htpasswd;
            }
    
    location @rewrite {
        # Forum
        rewrite    /threads/.*                /showthread.php?$uri&$args      last;
        rewrite    /forums/.*                /forumdisplay.php?$uri&$args    last;
        rewrite    /members/.*                /member.php?$uri&$args          last;
        rewrite    /blogs/.*                /blog.php?$uri&$args            last;
        rewrite    /entries/.*                /entry.php?$uri&$args           last;
        #rewrite    /content/.*                /content.php?$uri&$args           last;
       # rewrite    /widget/config/([0-9]+)                /widget.php?r=config/$1&$args           last;
        # rewrite ^widget/config/([0-9]+) widget.php?r=config/$1&$args           last;
          
    
    
    
    
        # MVC
        rewrite    ^/(?:(.*?)(?:/|$))(.*|$)$        /$1.php?r=$2                    last;
    
    
    
    
      }
    
      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;
    }
    Thanks
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,384
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    12:04 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    try commenting out the include line for include /usr/local/nginx/conf/block.conf; and restart Nginx
     
  5. computer19852007

    computer19852007 Member

    84
    8
    8
    Jun 25, 2014
    Ratings:
    +9
    Local Time:
    9:04 AM
    Centmin Mod 1.2.3-eva2000.06
    MariaDB 5.5.34
    Thank you very much @eva2000
    It Working

    Thanks
     
  6. eva2000

    eva2000 Administrator Staff Member

    54,384
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    12:04 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yeah the block.conf might have a few lines that cause problems, might need to remove some like

    Code:
    limit_req_status 444;
    if ($args ~ CtrlFunc_* ) {   return 444; }
    set $my_var 0;
    set $the_var 2;
    if ($request_method = POST ) {    set $my_var 1; }
    if ($args = / ) {    set $the_var 1; }
    if ($my_var = $the_var ) { return 444; }
    
    
    # from
    # http://www.howtoforge.com/nginx-how-to-block-exploits-sql-injections-file-injections-spam-user-agents-etc
    
        ## Block SQL injections
        set $block_sql_injections 0;
        if ($query_string ~ "union.*select.*\(") {
            set $block_sql_injections 1;
        }
        if ($query_string ~ "union.*all.*select.*") {
            set $block_sql_injections 1;
        }
        if ($query_string ~ "concat.*\(") {
            set $block_sql_injections 1;
        }
        if ($block_sql_injections = 1) {
            return 403;
        }
    
        ## Block file injections
        set $block_file_injections 0;
        if ($query_string ~ "[a-zA-Z0-9_]=http://") {
            set $block_file_injections 1;
        }
        if ($query_string ~ "[a-zA-Z0-9_]=(\.\.//?)+") {
            set $block_file_injections 1;
        }
        if ($query_string ~ "[a-zA-Z0-9_]=/([a-z0-9_.]//?)+") {
            set $block_file_injections 1;
        }
        if ($block_file_injections = 1) {
            return 403;
        }
    
        ## Block common exploits
        set $block_common_exploits 0;
        if ($query_string ~ "(<|%3C).*script.*(>|%3E)") {
            set $block_common_exploits 1;
        }
        if ($query_string ~ "GLOBALS(=|\[|\%[0-9A-Z]{0,2})") {
            set $block_common_exploits 1;
        }
        if ($query_string ~ "_REQUEST(=|\[|\%[0-9A-Z]{0,2})") {
            set $block_common_exploits 1;
        }
        if ($query_string ~ "proc/self/environ") {
            set $block_common_exploits 1;
        }
        if ($query_string ~ "mosConfig_[a-zA-Z_]{1,21}(=|\%3D)") {
            set $block_common_exploits 1;
        }
        if ($query_string ~ "base64_(en|de)code\(.*\)") {
            set $block_common_exploits 1;
        }
        if ($block_common_exploits = 1) {
            return 403;
        }
    If you do have time, you can try commenting some out until you find the problem :)
     
  7. computer19852007

    computer19852007 Member

    84
    8
    8
    Jun 25, 2014
    Ratings:
    +9
    Local Time:
    9:04 AM
    Centmin Mod 1.2.3-eva2000.06
    MariaDB 5.5.34
    i have remove it #Blocking HTTP POST Attack, after my forum working, but i don't know my forum will protect HTTP POST Attack

    Thank @eva2000
     
    Last edited: Jun 25, 2014
  8. eva2000

    eva2000 Administrator Staff Member

    54,384
    12,198
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,763
    Local Time:
    12:04 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yeah removing the following should fix it.. will actually update .07 beta 21 and remove these lines

    Code:
    limit_req_status 444;
    if ($args ~ CtrlFunc_* ) {   return 444; }
    set $my_var 0;
    set $the_var 2;
    if ($request_method = POST ) {    set $my_var 1; }
    if ($args = / ) {    set $the_var 1; }
    if ($my_var = $the_var ) { return 444; }