server {
listen 80;
server_name {$domain};
access_log /var/log/nginx/{$domain}_access_log;
error_log /var/log/nginx/{$domain}_error_log;
root {$path};
#不记录对站点图标访问
location = /favicon.ico {
log_not_found off;
access_log off;
}
#不记录对robots.txt的访问
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location = / {
try_files @proxy;
}
location / {
index index.htm index.html index.php;
try_files \$uri @proxy;
}
#匹配html
location ~* \.(html|htm)$ {
expires 30s;
gzip off;
add_header Content-Encoding gzip;
try_files \$uri \$uri/ /wp-content/cache/supercache/\$http_host/\$request_uri/index.html.gz @proxy;
}
#匹配图片、脚本文件等
location ~* \.(jpe?g|gif|png|ico|css|js|flv|swf|avi|zip|rar|svg|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mp3)$ {
expires 30d;
}
#传递给apache
location @proxy {
index index.htm index.html index.php;
proxy_pass http://127.0.0.1:81;
include /etc/nginx/proxy.conf;
}
}
|