Tips / Nginx

Nginx configuration for Xenforo

XenForo Nginx rewrite rules are pretty simple and can be configured within a few minutes. With this configuration you should have a perfectly working XenForo forum with friendly urls using Nginx. In this tutorial we will also cover the deny configuration for some critical directories like libraries and internal_data.

Let’s start.

Inside the server {} block, place two location sections like this:

location / {
        try_files $uri $uri/ /index.php?$uri&$args;

    location ~ /(internal_data|library) {

The first one is the friendly url rewriting and the second location is to preserve security in the critical directories.

In case your forum is not located at the root of your domain ( / ), and for example, you are calling it ‘forums’ or ‘xenforo’, you just simply need to add the name to the configuration, example:

location /xenforo/ {
        try_files $uri $uri/ /xenforo/index.php?$uri&$args;

    location ~ /xenforo/(internal_data|library) {

Restart Nginx:

service nginx restart

All done, now your Xenforo should be running fine with friendly urls using Nginx web server.

Popular search terms:

  • nginx error_page xenforo
  • xenforo nginx
  • friendly urls in nginx for xenforo
  • xenforo nginx configuration

Esteban Borges

Linux Geek, Webperf Addict, Nginx Fan. CTO @Infranetworking