Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
92 lines (73 sloc) 2.85 KB
server {
listen 80;
server_name www.<%= node['wp_install']['server_name'] %>;
rewrite ^ http://<%= node['wp_install']['server_name'] %>$request_uri? permanent;
}
server {
listen 80;
server_name <%= node['wp_install']['server_name'] %>;
root <%= node['wp_install']['server_root'] %>;
index index.php index.html index.htm
charset utf-8;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
set $do_not_cache <%= node['nginx']['do_not_cache'] %>;
# POST requests and urls with a query string should always go to PHP
if ($request_method = POST) {
set $do_not_cache 1;
}
# Don't cache uris containing the following segments
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
set $do_not_cache 1;
}
# Don't use the cache for logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $do_not_cache 1;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ .php$ {
try_files $uri /index.php;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
fastcgi_cache_bypass $do_not_cache;
fastcgi_no_cache $do_not_cache;
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 200 1d;
fastcgi_cache_valid any 10d;
}
location ~ /purge(/.*) {
fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
}
location ~ .*\.(html?|jpe?g|gif|png|css|js|ico|woff) {
access_log off;
expires <%= node['nginx']['expire'] %>;
}
location = /robots.txt { access_log off; log_not_found off; }
location ~ /\. { deny all; access_log off; log_not_found off; }
# ngx_pagespeed module
pagespeed <%= node['nginx']['pagespeed'] %>;
# Needs to exist and be writable by nginx.
pagespeed FileCachePath /var/ngx_pagespeed_cache;
# Ensure requests for pagespeed optimized resources go to the pagespeed handler
# and no extraneous headers get set.
location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
add_header "" "";
}
location ~ "^/ngx_pagespeed_static/" { }
location ~ "^/ngx_pagespeed_beacon$" { }
location /ngx_pagespeed_statistics { allow 127.0.0.1; deny all; }
location /ngx_pagespeed_global_statistics { allow 127.0.0.1; deny all; }
location /ngx_pagespeed_message { allow 127.0.0.1; deny all; }
location /pagespeed_console { allow 127.0.0.1; deny all; }
pagespeed RewriteLevel PassThrough;
pagespeed EnableFilters move_css_above_scripts,move_css_to_head;
pagespeed EnableFilters combine_css,rewrite_css,fallback_rewrite_css_urls;
pagespeed EnableFilters inline_css,extend_cache_css;
pagespeed EnableFilters rewrite_javascript,combine_javascript;
pagespeed EnableFilters defer_javascript,inline_javascript;
pagespeed EnableFilters lazyload_images;
pagespeed LazyloadImagesAfterOnload on;
}