server {
	listen 80 default_server;
	listen 443 ssl;

	# Doesn't really matter because default server, but this way email doesn't throw errors
	server_name localhost;

	access_log   /var/log/nginx/access.log;
	error_log    /var/log/nginx/error.log;

	root /var/www/html;
	index index.php;

	if (!-e $request_filename) {
		rewrite /wp-admin$ $scheme://$host$uri/ permanent;
		rewrite ^(/[^/]+)?(/wp-.*) $2 last;
		rewrite ^(/[^/]+)?(/.*\.php) $2 last;
	}

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

	location ~ \.php$ {
		try_files $uri =404;
		fastcgi_split_path_info ^(.+\.php)(/.+)$;

		include /etc/nginx/fastcgi_params;
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
	}

	location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
		access_log off; log_not_found off; expires max;

		add_header Access-Control-Allow-Origin *;
	}

	# This should match upload_max_filesize in php.ini
	client_max_body_size 100m;
}
