Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有AWS NLB&;的NGINX HTTP 499s;Gunicorn_Django_Django_Amazon Web Services_Nginx_Gunicorn_Aws Nlb - Fatal编程技术网

带有AWS NLB&;的NGINX HTTP 499s;Gunicorn_Django

带有AWS NLB&;的NGINX HTTP 499s;Gunicorn_Django,django,amazon-web-services,nginx,gunicorn,aws-nlb,Django,Amazon Web Services,Nginx,Gunicorn,Aws Nlb,我正在运行一个NGINX+Gunicorn安装程序,为AWS EC2s上的Django应用程序提供服务,该应用程序前面有一个网络负载均衡器。最近,我从我的NGINX获得了很多http499,它们都是连续的,而不是一次性的 AWS网络负载平衡器的固定空闲超时为350秒,我相信这是无法修改的。我的所有NGINX超时都设置为600 还有什么其他原因呢 下面是我的NGINX配置 user <someuser>; worker_processes auto; error_log /var/lo

我正在运行一个NGINX+Gunicorn安装程序,为AWS EC2s上的Django应用程序提供服务,该应用程序前面有一个网络负载均衡器。最近,我从我的NGINX获得了很多http499,它们都是连续的,而不是一次性的

AWS网络负载平衡器的固定空闲超时为350秒,我相信这是无法修改的。我的所有NGINX超时都设置为600

还有什么其他原因呢

下面是我的NGINX配置

user <someuser>;
worker_processes auto;
error_log /var/log/<somedir>/nginx_error_main.log;
pid /var/run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/<somedir>/nginx_access_main.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   600;
    types_hash_max_size 2048;

    proxy_ignore_client_abort on;

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

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    index   index.html index.htm;

    # Enable upgrading of connection (and websocket proxying) depending on the
    # presence of the upgrade field in the client request header
    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }

    # Create an upstream alias to where we've set daphne to bind to
    upstream django_app_server {
        server unix:/home/<somedir>/gunicorn.sock fail_timeout=0;
    }

    server {
        listen   8001 default;
        listen [::]:8001;
        server_name _;

        proxy_connect_timeout       600;
        proxy_send_timeout          600;
        proxy_read_timeout          600;
        send_timeout                600;

        client_max_body_size 4G;

        access_log /var/log/<somedir>/nginx-access.log;
        error_log /var/log/<somedir>/nginx-error.log;

        location /static/ {
            alias   /home/<somedir>/static/;
        }

        location /media/ {
            alias   /home/<somedir>/media/;
        }

        location / {
            # an HTTP header important enough to have its own Wikipedia entry:
            #   http://en.wikipedia.org/wiki/X-Forwarded-For
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            # enable this if and only if you use HTTPS, this helps Rack
            # set the proper protocol for doing redirects:
            # proxy_set_header X-Forwarded-Proto https;

            # pass the Host: header from the client right along so redirects
            # can be set properly within the Rack application
            proxy_set_header Host $http_host;

            # we don't want nginx trying to do something clever with
            # redirects, we set the Host: header above already.
            proxy_redirect off;

            # set "proxy_buffering off" *only* for Rainbows! when doing
            # Comet/long-poll stuff.  It's also safe to set if you're
            # using only serving fast clients with Unicorn + nginx.
            # Otherwise you _want_ nginx to buffer responses to slow
            # clients, really.
            # proxy_buffering off;

            # Try to serve static files from nginx, no point in making an
            # *application* server like Unicorn/Rainbows! serve static files.
            if (!-f $request_filename) {
                proxy_pass http://django_app_server;
                break;
            }
        }      
    }
}
用户;
工人自动处理;
error\u log/var/log//nginx\u error\u main.log;
pid/var/run/nginx.pid;
包括/usr/share/nginx/modules/*.conf;
事件{
工人(1024);;
}
http{
日志格式主“$remote\u addr-$remote\u user[$time\u local]“$request””
“$status$body\u bytes\u sent”$http\u referer”
“$http_user_agent”“$http_x_forwarded_for””;
access\u log/var/log//nginx\u access\u main.log main;
发送文件到;
tcp_nopush on;
tcp_节点延迟开启;
保持激活超时600;
类型\散列\最大\大小2048;
代理\u忽略\u客户端\u中止打开;
包括/etc/nginx/mime.types;
默认_类型应用程序/八位字节流;
#从/etc/nginx/conf.d目录加载模块化配置文件。
#看http://nginx.org/en/docs/ngx_core_module.html#include
#了解更多信息。
包括/etc/nginx/conf.d/*.conf;
index.html index.htm;
#启用连接升级(和websocket代理),具体取决于
#客户端请求标头中存在升级字段
映射$http\u升级$connection\u升级{
默认升级;
""关闭,;
}
#创建一个上游别名,将daphne绑定到该别名
上游django_应用程序_服务器{
服务器unix:/home//gunicorn.sock失败\u超时=0;
}
服务器{
听8001默认;
听[:]:8001;
服务器名称;
代理连接超时600;
代理发送超时600;
代理读取超时600;
发送超时600;
客户机最大机身尺寸4G;
access\u log/var/log//nginx-access.log;
error\u log/var/log//nginx-error.log;
位置/静态/{
别名/home//static/;
}
地点/媒体/{
别名/home//media/;
}
地点/{
#HTTP头非常重要,足以拥有自己的Wikipedia条目:
#   http://en.wikipedia.org/wiki/X-Forwarded-For
proxy\u set\u header X-Forwarded-For$proxy\u add\u X\u Forwarded\u For;
#当且仅当您使用HTTPS时启用此选项,这有助于
#设置执行重定向的正确协议:
#代理集头X转发协议https;
#从客户端直接传递Host:header,以便重定向
#可在机架应用程序中正确设置
代理设置头主机$http\U主机;
#我们不希望nginx试图用它做一些聪明的事情
#重定向时,我们已经在上面设置了Host:header。
代理_重定向关闭;
#执行此操作时,仅为彩虹设置“代理缓冲关闭”*
#Comet/long民意测验的东西。如果你是
#仅使用Unicorn+nginx服务快速客户端。
#否则,您希望nginx缓冲响应以降低速度
#客户,真的。
#代理缓冲关闭;
#尝试从nginx提供静态文件,没有必要
#*应用程序*服务器,如Unicorn/Rainbows!提供静态文件。
如果(!-f$request\u文件名){
代理通行证http://django_app_server;
打破
}
}      
}
}