server { listen 80; server_name cache.blog.tuinslak.* blog.tuinslak.*; access_log /var/log/nginx/blog.access.log; error_log /var/log/nginx/blog.error.log; #set your default location location / { # If logged in, don't cache. if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) { set $do_not_cache 1; } # mobile users if ($http_user_agent ~* '(iPhone|iPod|mobile|Android|2.0\ MMP|240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|hiptop|IEMobile)') { set $iphone_request '1'; } proxy_cache_key "$scheme://$host$request_uri $do_not_cache $iphone_request"; proxy_pass http://blog.yeri.be; proxy_cache blog; proxy_cache_valid 200 302 30m; proxy_cache_valid 404 5m; proxy_cache_valid any 10m; } location /sitemap.xml.gz { proxy_cache blog; proxy_cache_valid 200 302 5m; proxy_cache_valid 404 10m; proxy_cache_valid any 30m; proxy_pass http://blog.yeri.be; } location /sitemap.xml { proxy_cache blog; proxy_cache_valid 200 302 5m; proxy_cache_valid 404 10m; proxy_cache_valid any 30m; proxy_pass http://blog.yeri.be; } location ~* \.(jpg|png|gif|jpeg|css|js|mp3|wav|swf|mov|doc|pdf|xls|ppt|docx|pptx|xlsx|exe|dmg|txt|bmp|tar|gz|zip|rar|ico)$ { # Cache above file extentions for 7d proxy_cache blog; proxy_cache_valid 200 302 7d; proxy_cache_valid 404 60m; proxy_cache_valid any 60m; # setting a 10 day expiry time in the HTTP header expires 7d; proxy_pass http://blog.yeri.be; } location ~* wp\-.*\.php|wp\-admin { # Don't cache admin-looking things. Including wp*.php (wp-content uploads that end with .php, plugins, themes) proxy_pass http://blog.yeri.be; } location ~* \/[^\/]+\/(feed|\.xml)\/? { # Cache RSS looking feeds for 30 minutes unless logged in. if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) { set $do_not_cache 1; } # mobile users if ($http_user_agent ~* '(iPhone|iPod|mobile|Android|2.0\ MMP|240x320|AvantGo|BlackBerry|Blazer|Cellphone|Danger|DoCoMo|Elaine/3.0|EudoraWeb|hiptop|IEMobile)') { set $iphone_request '1'; } proxy_cache_key "$scheme://$host$request_uri $do_not_cache $iphone_request"; proxy_cache_valid 200 30m; proxy_cache_valid 404 5m; proxy_cache_valid any 10m; proxy_cache blog; proxy_pass http://blog.yeri.be; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /var/www/; } # No access to .htaccess files. location ~ /\.ht { deny all; } }