nginx日志格式与启用
# http 添加代码
# log_format main '$remote_addr [$time_local] $http_host $status "$request" $body_bytes_sent $http_referer $http_user_agent';
# service 添加代码
# access_log /home/wwwroot/xxxxx/access.log main;
nginx反代,与永久缓存
location ~ .*\.(html|htm|xml|js|css|gif|jpg|jpeg|png|bmp|swf|txt|ico|icon)$
{
set $myproxy "http://127.0.0.1:9030" ;
if ( $request_uri ~ /path/ ){
set $myproxy "http://127.0.0.1.140:9009" ;
}
if ( !-e $request_filename )
{
proxy_pass $myproxy ;
}
root /home/wwwroot/cache;
proxy_store on;
proxy_store_access user:rw group:rw all:r;
proxy_temp_path /home/wwwroot/cache;
proxy_set_header x-real-ip $remote_addr;
proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for;
proxy_set_header HOST $host;
}
root和alias区别
location /images/ {
root /home/wwwroot/;
}
http://domain.com/images/1.jpg ==> /home/wwwroot/images/1.jpg
location /images/ {
alias /home/wwwroot/;
}
http://domain.com/images/1.jpg ==> /home/wwwroot/1.jpg