Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Find full tutorial at: http://mikeg.de/project/cloud-nginx-server-wordpress/
- # wordpress-common.conf
- # Set a variable to work around the lack of nested conditionals
- set $cache_uri $request_uri;
- set $skip_cache 0;
- if ($query_string != "") {
- set $skip_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|\/wp-(app|cron|login|register|mail)\.php|wp\-comments\-popup\.php|wp\-links\-opml\.php|wp\-locations\.php") {
- set $skip_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 $skip_cache 1;
- }
- location ~ /purge(/.*) {
- fastcgi_cache_purge WORDPRESS "$scheme$request_method$host$1";
- }
- location / {
- # Use cached or actual file if they exists, otherwise pass request to WordPress
- #try_files $uri $uri/ /index.php?q=$uri&$args;
- try_files $uri $uri/ /index.php?q=$request_uri;
- # SECURITY
- if ($request_method !~ ^(GET|HEAD|POST)$ ) {
- return 444;
- }
- # POST requests and urls with a query string should always go to PHP
- if ($request_method = POST) {
- set $skip_cache 1;
- }
- # this serves static files that exist without running other rewrite tests
- if (-f $request_filename) {
- expires 30d; break;
- }
- }
- location ~ \.php$ {
- fastcgi_cache WORDPRESS;
- fastcgi_cache_valid 200 60m;
- include fastcgi_params;
- fastcgi_split_path_info ^(.+\.php)(/.+)$;
- # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
- fastcgi_pass unix:/var/run/php5-fpm.sock;
- fastcgi_param SCRIPT_FILENAME $request_filename;
- fastcgi_cache_bypass $skip_cache;
- fastcgi_no_cache $skip_cache;
- # Note: fastcgi_index is not needed is standard PHP location ~ \.php$ is useed: http://blog.martinfjordvald.com/2011/01/no-input-file-specified-with-php-and-nginx/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement