在nginx中请求超时

时间:2016-07-07 10:21:00

标签: django nginx http-status-codes request-timed-out

我在应用程序的服务器端(在nginx上)获得了499,在客户端获得了504。客户端的默认超时为5000秒,我得到的响应正好在60秒后。

以下是我的申请的https://<TEAM>.visualstudio.com/

nginx.conf

user www-data; worker_processes auto; pid /run/nginx.pid; events { worker_connections 768; # multi_accept on; } http { sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; underscores_in_headers on; include /etc/nginx/mime.types; default_type application/octet-stream; ## # SSL Settings ## ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; gzip_disable "msie6"; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } 是:

gunicorn config

有人可以告诉我为什么会发生这种情况?另外我怎么能纠正它。

1 个答案:

答案 0 :(得分:0)

长期执行命令我遇到了同样的问题。我用nginx config中的根端点的类似配置解决了这个问题:

location / { 
    proxy_pass http://127.0.0.1:8001; 
    ...
    proxy_connect_timeout 5000s; 
    proxy_read_timeout 5000s; 
}

注意proxy_connect_timeoutproxy_read_timeout

同样可能有用的是向用户返回一些快速响应,例如“正在处理...”或“正在加载...”并在后台运行主要任务。