Nginx and vBulletin 4.2.x inbuilt Friendly Urls:

For vBulletin 4.1.x using stock inbuilt Friendly Urls via mod_write, you will need to add additional Nginx rewrite rules within your domain's Nginx vhost configuration file /usr/local/nginx/conf/conf.d/newdomain.com.conf. This file is created when you use Centmin Mod's menu option #2 to 'Add Nginx vhost domain'.

First, enable vBulletin v4.1.x Friendly Urls Mod Rewrite in AdminCP:

vBulletin 4.1 Friendly Urls Mod Rewrite settings

Notes:

    1. Below Nginx rewrite rules were tested with vBulletin Suite v4.1.2 and work okay as far as I know. But I provide them as is, without support. If you need further help ask on Nginx forums.
    2. Centmin Mod v1.2.3-eva2000.03 made a change in /usr/local/lib/php.ini for security reasons to disable some PHP functions:

        disable_functions = exec,passthru,shell_exec,system,proc_open,popen
      

      For vB 4.2.x to work need to edit php.ini (shortcut command phpedit) and remove following listed functions exec,passthru,shell_exec,system leaving just proc_open,popen as most are needed for vB 4.2.x.

    3. Restart php-fpm service (shortcut command fpmrestart)
    4. Note: For vBulletin 4.2 you may encounter delays sending emails. In vB AdminCP -> Options -> Email set:

      • Enable -f paramater = yes
      • Use Cron Based Sending = no

      Cron based email sending was introduced in vB 4.2. I wrote an article on my blog at http://vbtechsupport.com/2003/ where for very busy vB 4.2 based forums this can cause very long delays for email to be sent as by default cron based emails will only send 10-50 emails every cron run and cron runs every 10mins by default so only 60-300 emails are sent per hour !

Nginx Rewrites for vBulletin 4.1.x Friendly Urls:

If vBulletin 4.1.x forum is installed in public web root i.e. /home/nginx/domains/newdomain.com/public, then you'll need to add and edit the following Nginx rewrites in /usr/local/nginx/conf/conf.d/newdomain.com.conf:

  location / {
    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;

    # MVC
    rewrite ^/(?:(.*?)(?:/|$))(.*|$)$       /$1.php?r=$2                    last;
}

The restart Nginx server for it to take effect:

  service nginx restart

or command shortcut

  ngxrestart

If vBulletin 4.1.x forum is installed off public web root in it's own directory i.e. /forums at /home/nginx/domains/newdomain.com/public/forums, then you'll need to add and edit the following Nginx rewrites in /usr/local/nginx/conf/conf.d/newdomain.com.conf:

  location /forums {
    try_files $uri $uri/ @rewrite;
}

        location /forums/includes {
        allow 127.0.0.1;
        deny all;
        }

        location /forums/packages {
        allow 127.0.0.1;
        deny all;
        }

        location /forums/vb {
        allow 127.0.0.1;
        deny all;
        }

        location /forums/admincp {
        include /usr/local/nginx/conf/php.conf;
        #auth_basic "Private";
        #auth_basic_user_file /usr/local/nginx/conf/htpasswd;
        }

location @rewrite {
        # Forum
        rewrite /forums/threads/.*                          /forums/showthread.php?$uri&$args      last;
        rewrite /forums/forums/.*                           /forums/forumdisplay.php?$uri&$args    last;
        rewrite /forums/members/.*                          /forums/member.php?$uri&$args          last;
        rewrite /forums/blogs/.*                            /forums/blog.php?$uri&$args            last;
        rewrite /forums/entries/.*                          /forums/entry.php?$uri&$args           last;

        # MVC
        rewrite ^/forums/(?:(.*?)(?:/|$))(.*|$)$            /forums/$1.php?r=$2                    last;
}

The restart Nginx server for it to take effect:

  service nginx restart

or command shortcut

  ngxrestart

Source: dotted


Password Protecting Admincp

Notice that admincp directory can be password protected but Nginx doesn't support .htaccess like Apache does. For Nginx you need to use HttpAuthBasicModule. For Centmin Mod Nginx installs, you can use the included python based tool, htpasswd.py to set up password protection files.

  1. You need to use to either create a password file or append to an existing file (i.e. /usr/local/nginx/conf/htpasswd).
  2. The password file can be named anything you like and created anywhere you like. Just do not place the file anywhere publicaly accessible i.e. not below /public web root. For this example chose /usr/local/nginx/conf/htpasswd.

To create a new /usr/local/nginx/conf/htpasswd with username and password use the following command like in SSH where you change username and password fields to one of your own choosing:

  python /usr/local/nginx/conf/htpasswd.py -c -b /usr/local/nginx/conf/htpasswd username password

To append to existing /usr/local/nginx/conf/htpasswd file, remove the -c option

  python /usr/local/nginx/conf/htpasswd.py -b /usr/local/nginx/conf/htpasswd username password

Then within admincp location of Nginx vhost uncomment (remove hash # in front of the 2 relevant lines):

        #auth_basic "Private";
        #auth_basic_user_file /usr/local/nginx/conf/htpasswd;

The restart Nginx server for it to take effect:

  service nginx restart

or command shortcut

  ngxrestart

Notes

Centmin Mod v1.2.3-eva2000.03 made a change in /usr/local/lib/php.ini for security reasons to disable some PHP functions:

  disable_functions = exec,passthru,shell_exec,system,proc_open,popen

For vB to work with ImageMagicK instead of the default GD for image resizing, do following:

  1. Edit php.ini (shortcut command phpedit) and remove exec from the list of disabled_functions
  2. Set ImageMagicK path to /usr/bin and save and select ImageMagicK
  3. Restart php-fpm service (shortcut command fpmrestart)