我正在尝试根据请求 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;
我知道我可以用if ($uri = /lbcheck.html) { access_log off; }inlocation @app但如果是邪恶的,所以我不想使用它们。