日志输出格式:
#这个要配置在http中
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
项目配置:
limit_req_zone $binary_remote_addr $uri zone=api_read:20m rate=50r/s;#查询
#报告
server {
listen 80;
server_name report.fuwuqijia.com;
index login.jsp;
access_log /usr/local/nginx/logs/report.fuwuqijia.com.access.log access;
#关闭静态文件的日志打印
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|css|js|ico)?$ {
expires 1d;
access_log off;
proxy_pass http://report;
}
location / {
limit_req zone=api_read burst=5;#请求限流,设置队列
proxy_pass http://report;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
upstream report {
fair;
server 172.16.1.120:8882 weight=1 max_fails=2 fail_timeout=30s;
server 172.16.1.120:8881 weight=1 max_fails=2 fail_timeout=30s;
}
