Vanilla Forum 2.1 Nginx Configuration

Are you already loosing you hair trying to configure your vanilla forum url-rewrite on NGINX?

If your forum is installed on a main domain not a subdomain I might have the solution for you. here’s what got, please let me know if it works for you…

server {
    listen       80;
    server_name  yourdomain.com;
    root   /usr/share/nginx/youvanilladirectory/;
    #access_log /usr/share/nginx/youvanilladirectory/access.log;
    access_log off;
    #error_log /usr/share/nginx/youvanilladirectory/error.log;
    error_log off;
    index  index.php index.html index.htm;
    #Root location
    location ^~ /discussion/download/ { rewrite ^/(.+)$ /index.php?p=$1 last;}
    location ^~ /utility/thumbnail/ { rewrite ^/(.+)$ /index.php?p=$1 last;}
    location / {
        try_files $uri $uri/ @forum;
    }
    # Rewrite to prettify the URL and hide the ugly PHP stuff
    # Start with this commented out until you configure it in Vanilla!
    location @forum {
        rewrite ^/(.+)$ /index.php?p=$1 last;
    }
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
    location ~* \.(js|css|png|jpg|jpeg|gif|ico)(\?ver=[0-9.]+)?$ {
        expires 1y;
    }
}

3 Comments

  1. Chris
    January 21, 2015

    hey man! just tried this out on my site, works like a charm. i also was able to use a subdomain without an issue. thanks for sharing!

    Reply
  2. Tom Dworzanski
    February 13, 2015

    Turning your logs off is probably not a good idea.

    Reply
    1. admin
      February 18, 2015

      hehe, Im a cpu resource freak. i do turn it on and off though from time to time when I need, somehow this small configuration tweak allows me to to run it efficiently on a 512mb ram VPS. turning logs on somehow give my cpu resource a little spike. 🙂

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *