tantita
1/6/2013 - 12:57 AM

Altered, VanillaForums Nginx/PHP-FPM host config

Altered, VanillaForums Nginx/PHP-FPM host config

# http://blog.bigdinosaur.org/vanilla-forum-on-nginx/
server {
	server_name forum.frameworks.loc;
	root /var/www/frameworks/forum/public;

	index index.php default.php index.html;
	autoindex off;

	# Root location
	location / {
		try_files $uri $uri/ @forum;
	}

	# Rewrite to prettify the URL and hide the ugly PHP stuff
	location @forum {
		# Start with this commented out until you configure it in Vanilla!
		# rewrite ^/(.+)$ /index.php?p=$1 last;
	}

	# PHP handler
	location ~ \.php {
		try_files $uri =404;
		include fastcgi_params;
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_split_path_info ^(.+\.php)(.*)$;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		#fastcgi_intercept_errors on;
	}

	# Stop things from executing in the uploads directory
	location ~* ^/uploads/.*.(html|htm|shtml|php)$ {
		types { }
		default_type text/plain;
	}

	# Keep nosey people from discivering categories by number
	location ~* /categories/([0-9]|[1-9][0-9]|[1-9][0-9][0-9])$ {
		return 404;
	}

	# Deny, drop, or internal locations
	location ~ /\. { access_log off; log_not_found off; deny all; }
	location ~ ~$ { access_log off; log_not_found off; deny all; }
	location = /robots.txt { access_log off; log_not_found off; }
	location ^~ favicon { access_log off; log_not_found off; }
	location ^~ /conf/ { internal; }

	# Taking advantage of browser caching for static stuff
	location ~* \.(js|css|png|jpg|jpeg|gif|ico|eot|woff|ttf|svg)$ {
		expires max;
		log_not_found off;
	}

	# Plug-in specific rules

	# Keep the WhosOnline plugin from flooding the logs
	location /plugin/imonline { access_log off; log_not_found off; }
}