AWS ALB随机504网关超时

时间:2020-04-08 03:22:18

标签: amazon-web-services nginx aws-application-load-balancer

这是我的设置:

ALB(在端口443上侦听)-> NGINX(在端口444上侦听,因为$ host在EC2 proxy_pass上使用了443)

我的问题是,每当我通过ALB使用HTML时,我只会每隔一次拉HTML。我知道这不是我的Nginx配置,因为如果我这样做

curl --location -vvv -k 'https://$EC2_IP:444' -H 'Host: $FORWARD_HOST.LOCAL'

我每次都会提取HTML,即使我执行了for循环并将其真正垃圾了。有什么想法要解决,还是以前有人遇到过这个问题?

更新:经过更多的挖掘,看起来可能是request_processing_time的元凶:

如果负载均衡器无法将请求分派到目标,则此值设置为-1。如果目标在空闲超时之前关闭了连接,或者客户端发送了格式错误的请求,则会发生这种情况。

在修改我的nginx.conf后将报告回来。我已经调整了所有我认为无济于事的方法:/

nginx.conf
user nginx;

worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
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/nginx/access.log  main;

    resolver 127.0.0.1;
    resolver_timeout 60s;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   62s;
    types_hash_max_size 2048;

    # 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;

    # Settings for a TLS enabled server.

    server {
        listen       444 ssl default_server;
        listen       [::]:444 ssl default_server;
        server_name  _;

        ssl_password_file /etc/nginx/my_certs/password_file;
        ssl_certificate /etc/nginx/my_certs/my.pem;
        ssl_certificate_key /etc/nginx/my_certs/my.key;
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  1m;
        ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location ^~ /proxycheck {
            return 200 'available';
            add_header Content-Type text/plain;
        }

        location / {
            set $upstream_endpoint https://$http_host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   Host      $http_host;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            proxy_pass $upstream_endpoint;
        }

    }

}

/etc/nginx/conf.d/timeout.conf

proxy_connect_timeout 600;
proxy_send_timeout 600;
proxy_read_timeout 600;

0 个答案:

没有答案
相关问题