• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
  • This forum has been archived. New threads and replies may not be made. All add-ons/resources that are active should be migrated to the Resource Manager. See this thread for more information.

How to get your pet nginx to play well with your new toy Xenforo

nginx can be a moody pet. It can refuse to play well with older toys or decide to randomly pee on crappy toys... like those rhyming with umm... Dbulletin. yeah that's it. anyhoo. Now that you have decided to switch to the cadillac of toys. i.e. Xenforo, what can you do to make it so nginx loves and cherishes it like you do? well simple! follow the basic steps below to make it all go smooth like some kind of smoothing agent! like astroglide... umm. yeah thats it. *cough*... on to stuff that matters.

scene setting :
your domain will be example.com
your root will be /var/www/
your logs will be in /var/log/
your nginx servers listens to *all* IPs and port 80

So edit these values to your hearts content ... before you do anything else like go live with them.

I will skip the part where you install nginx. theres plenty of resources out there. just google.

now say you want people to only goto http://www.example.com and not http://example.com well thats simple! the easiest and most surefire way I know of how to do this is setup two blocks in the domain file under sites-available or wherever you store them.

server {
listen 80;
server_name example.com; # your domain name
rewrite ^(.*)$ http://www.example.com$1 permanent; # your domain name with www.
server {
listen 80;
server_name www.example.com; # your domain name WITH www.
access_log /var/log/example.com.access.log;
error_log /var/log/example.com.error.log;
index index.php index.html index.htm;

location ~ /\.ht { deny all; } # Anything starting with .ht gets denied

location ~* \.(bmp|tiff|tga|jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|wav|bmp|rtf|js|7z|tar|lzma)$ { # serve all these static files without hitting the php processor
root /var/www; # you dont have to be explicit about this but incase you need to proxy stuff to another server this static stuff will still go through nginx
expires max;

location / { # basic root of the domain
root /var/www; # absolute path to your installation
try_files $uri $uri/ /index.php?$uri&$args;

location ~ \.php$ {
fastcgi_pass backend; # address/port where FastCGI processes were spawned
fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
above code looks horrible as a quote so its also attached in a file below.
for the record I use php-fpm which is now part of default php. its awesome. also use APC with it... it cuts my resource usage a decent amount.

Apologies on any typos, feel free to ask any questions :) yes its my first post here so I might be unaware of something I should do/add/remove, please let me know. thanx.



Well-known member
From that mentioned thread, you may also want to protect a couple of directories on your xenforo installation:
#no access
    location /xf/internal_data/ {
      root  /blah/blah/public;


#no access
    location /xf/library/ {
      root  /blah/blah/public;