Created
March 26, 2012 14:36
-
-
Save abackstrom/2205544 to your computer and use it in GitHub Desktop.
Nginx + php-fpm for WordPress Network
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 69.164.216.5:80; | |
listen 69.164.216.5:443 default ssl; | |
server_name _; | |
ssl_certificate ssl/sixohthree.com.cert.pem; | |
ssl_certificate_key ssl/sixohthree.com.key.pem; | |
root /var/www/mu.sixohthree.com/html; | |
server_name_in_redirect off; | |
access_log /var/www/mu.sixohthree.com/logs/access_log custom; | |
error_log /var/www/mu.sixohthree.com/logs/error_log error; | |
log_subrequest off; | |
index index.php; | |
location / { | |
rewrite ^.*/files/(.*) /wp-includes/ms-files.php?file=$1 last; | |
if (!-e $request_filename) { | |
rewrite ^.+?(/wp-.*)$ $1 last; | |
rewrite ^.+?(/.*\.php)$ $1 last; | |
rewrite ^ /index.php last; | |
} | |
} | |
location /~adam/ { | |
alias /home/adam/blog/; | |
} | |
location /~ { | |
return 410; | |
} | |
location /blogs.dir { | |
internal; | |
alias /var/www/mu.sixohthree.com/html/wp-content/blogs.dir; | |
expires 30d; | |
} | |
location ~ ^/(status|ping)$ { | |
include fastcgi_params; | |
fastcgi_pass unix:/var/run/php-fpm.sock; | |
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; | |
} | |
if ($server_port = 443) { set $https on; } | |
if ($server_port = 80) { set $https off; } | |
location ~ \.php$ { | |
if (!-e $request_filename) { | |
rewrite ^.+?(/.*\.php)$ $1 last; | |
} | |
set $no_cache ""; | |
if ( $request_method !~ ^(GET|HEAD)$ ) { | |
set $no_cache "1"; | |
} | |
if ( $http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) { | |
set $no_cache "1"; | |
} | |
if ($no_cache = "1") { | |
add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/"; | |
add_header X-Microcachable "0"; | |
} | |
if ($http_cookie ~* "_mcnc") { | |
set $no_cache "1"; | |
} | |
fastcgi_no_cache $no_cache; | |
fastcgi_cache_bypass $no_cache; | |
fastcgi_cache mu; | |
fastcgi_max_temp_file_size 1M; | |
fastcgi_cache_valid 200 1s; | |
fastcgi_cache_key $scheme$host$request_method$request_uri; | |
fastcgi_cache_use_stale updating; | |
fastcgi_pass unix:/var/run/php-fpm.sock; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME /var/www/mu.sixohthree.com/html/$fastcgi_script_name; | |
fastcgi_param HTTPS $https; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment