Skip to content

Instantly share code, notes, and snippets.

@remear
Created August 16, 2010 16:36
Show Gist options
  • Save remear/527239 to your computer and use it in GitHub Desktop.
Save remear/527239 to your computer and use it in GitHub Desktop.
server {
server_name myhost.com;
listen 80;
error_log /var/log/myhost.com-error.log;
access_log /var/log/myhost.com-access.log;
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /WebServer/Documents/myhost$fastcgi_script_name;
}
location / {
gzip on;
gzip_http_version 1.0;
gzip_vary on;
gzip_comp_level 3;
gzip_proxied any;
gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss$
gzip_buffers 16 8k;
root /WebServer/Documents/myhost;
index index.php index.html index.htm;
# if the requested file exists, return it immediately
if (-f $request_filename) {
break;
}
set $supercache_file '';
set $supercache_uri $request_uri;
if ($request_method = POST) {
set $supercache_uri '';
}
# Using pretty permalinks, so bypass the cache for any query string
if ($query_string) {
set $supercache_uri '';
}
if ($http_cookie ~* "comment_author_|wordpress|wp-postpass_" ) {
set $supercache_uri '';
}
# if we haven't bypassed the cache, specify our supercache file
if ($supercache_uri ~ ^(.+)$) {
set $supercache_file /wp-content/cache/supercache/$http_host/$1index.html;
}
# only rewrite to the supercache file if it actually exists
if (-f $document_root$supercache_file) {
rewrite ^(.*)$ $supercache_file break;
}
# all other requests go to WordPress
if (!-e $request_filename) {
rewrite . /index.php last;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment