Created
September 12, 2013 22:07
-
-
Save windyjonas/6544493 to your computer and use it in GitHub Desktop.
nginx conf file included in all local WordPress dev sites.
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
fastcgi_intercept_errors on; | |
if ($http_user_agent ~* (HTTrack|HTMLParser|discobot|Exabot|Casper|kmccrew|plaNETWORK|RPT-HTTPClient)) { | |
return 444; | |
} | |
if ($http_referer ~* (sex|vigra|viagra) ) { | |
return 444; | |
} | |
location / { | |
try_files $uri $uri/ /index.php?q=$uri&$args; | |
} | |
location ~ /\. { | |
deny all; | |
} | |
location ~ ^/(run|wp-)cron\.php { | |
allow ADD-LOCAL-HOST-IP; | |
deny all; | |
include fastcgi.conf; | |
fastcgi_pass fpm; | |
error_log /var/log/nginx/wp_cron.log error; | |
} | |
location ~* ^.+\.(css|js|jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ { | |
expires max; | |
access_log off; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
include fastcgi.conf; | |
error_log /var/log/nginx/wp.log error; | |
set $nocache ""; | |
set $cache_control max-age=12; | |
if ($http_cookie ~ (comment_author_.*|wordpress_logged_in.*|wp-postpass_.*)) { | |
set $nocache "Y"; | |
set $cache_control no-cache; | |
} | |
fastcgi_hide_header X-Pingback; | |
fastcgi_pass fpm; | |
fastcgi_cache_use_stale error timeout invalid_header http_500; | |
fastcgi_hide_header "Pragma"; | |
fastcgi_hide_header "Cache-Control"; | |
fastcgi_cache img; | |
fastcgi_cache_valid 200 1m; | |
fastcgi_cache_valid 404 1m; | |
fastcgi_cache_bypass $nocache; | |
fastcgi_no_cache $nocache; | |
add_header Cache-Control $cache_control; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment