Nginx Server Config

Skip to end of metadata
Go to start of metadata

Here is an example config for a MODX installation on an nginx server (php-fpm is required for nginx servers). This example enables MODX FURLs as well.

server {
	listen 80;
	server_name example.com www.example.com;
	root /home/sites/example.com;
	index index.php;
	client_max_body_size 30M;
	location / {
		root /home/sites/example.com;
		if (!-e $request_filename) {
			rewrite ^/(.*)$ /index.php?q=$1 last;
		}
	}
	location ~ \.php$ {
                try_files $uri =404;
		fastcgi_split_path_info ^(.+\.php)(.*)$;
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  index.php;
		fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
		include fastcgi_params;
		fastcgi_ignore_client_abort on;
		fastcgi_param  SERVER_NAME $http_host;
	}

	location ~ /\.ht {
		deny  all;
	}
}

An alternative server configuration was suggested in this forum topic.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Aug 17, 2011

    Mike Reid says:

    Thanks for posting this, complete with FURL support :) Question: With root /hom...

    Thanks for posting this, complete with FURL support :)

    Question: With root /home/sites/example.com; defined at the server level, is it necessary to include again in the first location block?
    My understanding is that nginx configs are inherited from the top down, and therefore it could be removed in this case...