Skip to content

Instantly share code, notes, and snippets.

@kokuyouwind
Created June 8, 2014 10:19
Show Gist options
  • Save kokuyouwind/8abb2dee7b64e50ddd41 to your computer and use it in GitHub Desktop.
Save kokuyouwind/8abb2dee7b64e50ddd41 to your computer and use it in GitHub Desktop.
server {
listen 80 default;
server_name _;
root /var/www/vhosts/default;
index index.html index.htm;
charset utf-8;
access_log /var/log/nginx/default.access.log main;
error_log /var/log/nginx/default.error.log;
include /etc/nginx/drop;
rewrite /wp-admin$ $scheme://$host$uri/ permanent;
#rewrite ^(.*)(index|home|default)\.html? $1 permanent;
set $mobile '';
#include /etc/nginx/mobile-detect;
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;
}
#location ~* \.(js|css|html?|xml|gz|jpe?g|gif|png|swf|wmv|flv|ico)$ {
# index index.html index.htm;
# include /etc/nginx/expires;
#}
location / {
if ($request_filename ~ .*\.php) {
break;
proxy_pass http://backend;
}
include /etc/nginx/expires;
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;
}
#
# When you use phpMyAdmin, uncomment the line "include /etc/nginx/phpmyadmin;"
# and delete or comment out the below line "location ~* /(phpmyadmin|myadmin|pma) { }".
#
#include /etc/nginx/phpmyadmin;
location ~* /(phpmyadmin|myadmin|pma) {
access_log off;
log_not_found off;
return 404;
}
#
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment