Created
November 14, 2014 07:41
-
-
Save ftkro/20c755f535913a948169 to your computer and use it in GitHub Desktop.
Nginx Frontend
This file contains 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
server { | |
listen 80 default; | |
server_name _; | |
root /path/to/your/root/directory; | |
index index.html index.htm; | |
charset utf-8; | |
access_log /var/log/nginx/domain.access.log main; | |
error_log /var/log/nginx/domain.error.log; | |
rewrite ^(.*)(index|home|default)\.html? $1 permanent; | |
set $mobile ''; | |
include /etc/nginx/template/mobile-detect; | |
location ~* ^/wp-(admin|includes) { | |
index index.php index.html index.htm; | |
if ($request_filename ~ .*\.php) { | |
expires off; | |
proxy_pass http://backend; | |
} | |
expires 2m; | |
} | |
location /feed { | |
expires off; | |
proxy_pass http://backend; | |
} | |
location / { | |
if ($request_filename ~ .*\.php) { | |
break; | |
proxy_pass http://backend; | |
} | |
open_file_cache max=100; | |
include /etc/nginx/template/expires; | |
set $do_not_cache 0; | |
if ($http_cookie ~* "comment_author_|wordpress_(?!test_cookie)|wp-postpass_" ) { | |
set $do_not_cache 1; | |
} | |
if ($request_method = POST) { | |
set $do_not_cache 1; | |
} | |
proxy_no_cache $do_not_cache; | |
proxy_cache_bypass $do_not_cache; | |
proxy_redirect off; | |
proxy_cache czone; | |
proxy_cache_key "$scheme://$host$request_uri$mobile"; | |
proxy_cache_valid 200 0m; | |
proxy_pass http://backend; | |
} | |
location ~ /(Your favorite Purge dir)(/.*) { | |
proxy_cache_purge czone "$scheme://$host$1$is_args$args$mobile"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment