【问题标题】:How to increase the nginx request timeout?如何增加nginx请求超时?
【发布时间】:2013-01-23 16:55:50
【问题描述】:

我的网络服务器正在处理一个巨大的文件,然后发送响应。我已经尝试了各种 nginx 超时参数,但没有运气。 this question推荐的参数我试过了,但是在nginx的错误日志里还是看到超时页面报错。

1 upstream prematurely closed connection while reading response header from upstream,client: 10.0.42.97, server: 

这是我的 nginx.conf

http {
     include       /etc/nginx/mime.types;
     default_type  application/octet-stream;

     access_log    /var/log/nginx/access.log;

     sendfile on;
     tcp_nopush on;
     tcp_nodelay on;

     keepalive_timeout  65;

     client_header_timeout 600;
     client_body_timeout 600;
     send_timeout 600;
     proxy_read_timeout 600;

     fastcgi_buffers 8 16k;
     fastcgi_buffer_size 32k;
     fastcgi_read_timeout 600;

     gzip  on;
     gzip_http_version 1.0;
     gzip_comp_level 2;
     gzip_proxied any;
     gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript application/json;

     server_names_hash_bucket_size 64;

     include /etc/nginx/conf.d/*.conf;
     include /etc/nginx/sites-enabled/*;
     }

我仍然不时看到 502 Bad gateway,出现上述错误。关于什么可能是错误的任何指示?我的输入文件是一个 csv 文件,如果有帮助的话。有什么指点或建议吗?

我该如何解决这个问题?如何增加超时时间?

【问题讨论】:

  • This 可以帮助希望增加超时的人。

标签: nginx


【解决方案1】:

这里不是 Nginx 的问题,它是处理您正在上传的文件的脚本。如果您使用 PHP,则必须更改 php.ini 中的设置以允许更长的超时和更大的上传。可能需要增加的设置是:

max_execution_time
max_input_time
memory_limit
post_max_size
upload_max_filesize

如果您使用不同的脚本语言,您应该寻找控制最大上传大小、最大脚本执行时间和内存限制的设置。只要 Nginx 返回错误的网关错误,通常你的处理后端就有问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-04-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-11
    • 2016-07-21
    相关资源
    最近更新 更多