Nginx vBulletin 5 Configuration

Configure Nginx vhost for vBulletin Connect 5.0.4+ subdirectory and web root installs on Centmin Mod.

Nginx and vBulletin Connect 5 Vhost

vBulletin 5.0.4 was released with Nginx support. Versions prior to 5.0.4 will need to upgrade for Nginx to work properly.

General Notes

  • The vB 5 download includes an nginx.vhost file in the do_not_upload folder. The below information is only for Centmin Mod installed Nginx servers.
  • Your domain's Nginx vhost configuration file is at /usr/local/nginx/conf/conf.d/yourdomainname.com.conf, created via menu option #2.
  • For vB to work with ImageMagick, edit php.ini (phpedit) and remove all disabled functions, then restart php-fpm (fpmrestart).

vBulletin 5.0.4+ Subdirectory Installs

Nginx vhost for vBulletin 5.0.4+ in subdirectory yourdomainname.com/504:

server {{
    listen   80;
    server_name yourdomainname.com www.yourdomainname.com;

    access_log /home/nginx/domains/yourdomainname.com/log/access.log combined buffer=32k;
    error_log /home/nginx/domains/yourdomainname.com/log/error.log;

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

    location / {{
    }}

    include /home/nginx/domains/yourdomainname.com/includes/vb504.conf;

    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/phpvb5.conf;
    include /usr/local/nginx/conf/drop.conf;
    include /usr/local/nginx/conf/vts_server.conf;
}}

Contents of /home/nginx/domains/yourdomainname.com/includes/vb504.conf:

# legacy css being handled separate for performance
location ^~ /504/css.php {{
    include /usr/local/nginx/conf/phpvb5.conf;
    rewrite ^ /504/core/css.php break;
}}

# make install available from root
location ~ /504/install/ {{
    rewrite ^ /504/core/install/ break;
}}

# any request to non-existing item redirected through routestring
location ^~ /504/ {{
    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/phpvb5.conf;
    if (!-f $request_filename) {{
        rewrite ^/504/(.*)$ /504/index.php?routestring=$1 last;
    }}
}}

location /504/core/(includes|vb|cache|libraries|vb5)/ {{
    allow 127.0.0.1;
    deny all;
}}

# make admincp available from root
location ^~ /504/admincp {{
    #auth_basic "Private";
    #auth_basic_user_file /usr/local/nginx/conf/htpasswd;
    if (!-f $request_filename) {{
        rewrite /504/admincp/(.*)$ /504/index.php?routestring=admincp/$1 last;
    }}
}}

vBulletin 5.0.4+ Web Root Installs

Nginx vhost for vBulletin 5.0.4+ installed from web root:

server {{
    listen   80;
    server_name yourdomainname.com www.yourdomainname.com;

    access_log /home/nginx/domains/yourdomainname.com/log/access.log combined buffer=32k;
    error_log /home/nginx/domains/yourdomainname.com/log/error.log;

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

    location ^~ /css.php {{
        include /usr/local/nginx/conf/phpvb5.conf;
        rewrite ^ /core/css.php break;
    }}

    location ~ /install/ {{
        rewrite ^ /core/install/ break;
    }}

    location ^~ / {{
        include /usr/local/nginx/conf/staticfiles.conf;
        include /usr/local/nginx/conf/phpvb5.conf;
        if (!-f $request_filename) {{
            rewrite ^/(.*)$ /index.php?routestring=$1 last;
        }}
    }}

    location /core/(includes|vb|cache|libraries|vb5)/ {{
        allow 127.0.0.1;
        deny all;
    }}

    location ^~ /admincp {{
        #auth_basic "Private";
        #auth_basic_user_file /usr/local/nginx/conf/htpasswd;
        if (!-f $request_filename) {{
            rewrite /admincp/(.*)$ /index.php?routestring=admincp/$1 last;
        }}
    }}

    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/phpvb5.conf;
    include /usr/local/nginx/conf/drop.conf;
    include /usr/local/nginx/conf/vts_server.conf;
}}

You also need to create /usr/local/nginx/conf/phpvb5.conf with the PHP-FPM fastcgi configuration for vB5. Restart Nginx and PHP-FPM: nprestart

Password Protecting AdminCP

Use the included htpasswd.sh tool:

/usr/local/nginx/conf/htpasswd.sh create /usr/local/nginx/conf/htpasswd username password

To append, use append instead of create. Then uncomment the auth_basic lines and restart Nginx.