【问题标题】:Nginx setting timeout for dav_methodsNginx 为 dav_methods 设置超时
【发布时间】:2019-11-08 17:49:28
【问题描述】:

我有一个 Nginx 实例,用作 Bazel 缓存,配置如下。我想为 PUT (dav_methods) 请求设置一个较短的(4 秒)超时。

http {
  ...
  # request timed out
  client_body_timeout 2;
  client_header_timeout 2;

  # server will close connection
  keepalive_timeout 5;

  send_timeout 1;

  gzip on;

  server {
    listen 80 default_server;
    server_name _;

    location ~ "<my regex>" {
      root <my dir>;
      dav_methods PUT;
      limit_except PUT GET { deny all; }
      create_full_put_path on;
    }
  }
}

使用上面的配置。我从未见过 GET 请求响应时间超过 2 秒,但 PUT 请求有时需要 30-80 秒而不会超时。

我是否缺少设置?

【问题讨论】:

  • 我找不到修复程序;但是,我确实将错误日志更改为调试模式,并且能够找到/修复几个问题。 error_log /var/log/nginx/error.log debug;

标签: nginx timeout bazel nginx-config


【解决方案1】:

这可能会帮助你https://www.nginx.com/blog/tuning-nginx/

尤其是限制部分,

您可以设置各种限制来帮助防止客户消费 资源过多,可能会对系统性能产生不利影响 以及安全性和用户体验。

如果您使用代理,这些可能会有所帮助

 fastcgi_read_timeout 3600s;
 proxy_connect_timeout       600;
 proxy_send_timeout          600;
 proxy_read_timeout          600;
 send_timeout                600;

https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_read_timeout

https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_connect_timeout

https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout

https://nginx.org/en/docs/http/ngx_http_core_module.html#send_timeout

【讨论】:

  • 感谢您的回答。在这种情况下,nginx 不用作代理,也不使用 fastcgi。
猜你喜欢
  • 1970-01-01
  • 2022-09-23
  • 1970-01-01
  • 2010-10-10
  • 2010-09-27
  • 2017-07-31
  • 1970-01-01
  • 2010-12-21
  • 2015-12-17
相关资源
最近更新 更多