我想基于请求URI在nginx日志中“忽略”或重定向某些请求。
到目前为止,我有这个:
server {
listen 80;
#...
access_log /var/log/nginx/site.access;
error_log /var/log/nginx/site.error info;
#...
try_files $uri @app
location = /lbcheck.html {
access_log off;
log_not_found off;
try_files $uri @app;
}
location @app {
proxy_redirect off;
proxy_pass http://unix:/tmp/site.unicorn.sock;
#...
}
}
基本上,我希望被代理的@app响应请求/lbcheck.html
,但我不想在/var/log/nginx/site.access
中记录它。我知道可以在
location @app
中使用if ($uri = /lbcheck.html) { access_log off; }
来实现,但是if语句是不好的,所以我不想使用它们。