Nginx vBulletin 4 Friendly URLs

Configure Nginx rewrite rules for vBulletin 4.1.x inbuilt friendly URLs on Centmin Mod.

Nginx and vBulletin 4.2.x Inbuilt Friendly URLs

For vBulletin 4.1.x using stock inbuilt Friendly URLs via mod_rewrite, 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.

Notes: Below Nginx rewrite rules were tested with vBulletin Suite v4.1.2. Provided as-is, without support. For further help ask on Nginx forums.

Centmin Mod made a change in /usr/local/lib/php.ini for security to disable some PHP functions. For vB 4.2.x you need to edit php.ini (shortcut phpedit) and remove exec,passthru,shell_exec,system leaving just proc_open,popen. Then restart php-fpm (shortcut fpmrestart).

Email Note: For vBulletin 4.2 you may encounter delays sending emails. In vB AdminCP → Options → Email set: Enable -f parameter = yes, Use Cron Based Sending = no.

Nginx Rewrites for vBulletin 4.1.x (Web Root Install)

If vBulletin 4.1.x is installed in public web root at /home/nginx/domains/newdomain.com/public:

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;
}}

Restart Nginx: service nginx restart or shortcut ngxrestart

Nginx Rewrites for vBulletin 4.1.x (Subdirectory Install)

If vBulletin 4.1.x is installed in /home/nginx/domains/newdomain.com/public/forums:

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 {{
    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;
}}

Password Protecting AdminCP

Nginx does not support .htaccess like Apache. Use HttpAuthBasicModule with the included htpasswd.py tool:

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

To append to existing file, remove the -c option. Then uncomment the auth_basic lines in the admincp location block and restart Nginx.

ImageMagick Notes

For vB to work with ImageMagick instead of GD for image resizing: edit php.ini (phpedit) and remove exec from disabled_functions, set ImageMagick path to /usr/bin, then restart php-fpm (fpmrestart).