jimmyjamieson
8/27/2014 - 3:03 PM

Nginx Config for Craft CMS / BuildWithCraft

Nginx Config for Craft CMS / BuildWithCraft

server {
	listen 8080;
	#listen [::]:80 default_server ipv6only=on;

	root /var/www/craftsite.com/public;
	index index.php index.html index.htm;

	# Make site accessible from http://localhost/
	server_name craftsite.com;

	port_in_redirect off;
  	server_tokens off;
  	autoindex off;

 	# Define default caching of 24h
    	expires 86400s;
    	add_header Pragma public;
    	add_header Cache-Control "max-age=86400, public, must-revalidate, proxy-revalidate";


	location ~ \.php$ {
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
		fastcgi_pass unix:/var/run/php5-fpm.sock;
		fastcgi_index index.php;
		include fastcgi_params;
	}

	location ~ ^(.*)$ {
	    try_files $uri $uri/ /index.php?p=$uri&$args;
	}

    location ~* \.(?:ico|css|js|gif|jpe?g|png)$ {
        expires max;
        add_header Pragma public;
        add_header Cache-Control "public, must-revalidate, proxy-revalidate";
    }

  location = /robots.txt  { access_log off; log_not_found off; }
  location = /favicon.ico { access_log off; log_not_found off; }
  location ~ /\. { access_log off; log_not_found off; deny all; }

}