【发布时间】:2020-05-14 13:23:45
【问题描述】:
因此,我们需要将任何流向 /notifications 中的 nginx 的流量代理到 AWS ALB。
如果我们直接为 ALB 创建一个 websocket,它会在 3:10 秒后关闭,这就是我们配置的超时时间。
但是,当我们从前端代理通道尝试时,我们无法获得大于 60 秒的超时。我已经关注了几乎所有我能找到的关于此事的帖子,所以这是我们的配置:
location /notifications/internal/ {
rewrite ^/notifications/internal /notinternal last;
}
location /notifications {
rewrite ^/notifications(/|$)(.*) /$2 break;
proxy_pass https://ALB;
proxy_pass_request_headers on;
proxy_read_timeout 3600s;
proxy_connect_timeout 3600s;
proxy_send_timeout 3600s;
send_timeout 3600s;
proxy_socket_keepalive on;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
正好在 60 年代之后,我们总是会看到这个日志:
10.31.0.22 - - [14/May/2020:13:15:16 +0000] "GET /notifications/ws HTTP/1.1" response 101 body-bytes 100 upstream_resp_time 60.002 req_time 60.001 req_bytes 373 vhost x.x country - cf_connecting_ip - cf_ray -
我尝试在 nginx.conf 中添加更大的超时时间,但似乎没有任何效果。
我尝试将代理通行证放入上游块,但它似乎不起作用,我得到 404 not found。
现在我知道 nginx 在这方面发挥了作用,就好像我将超时设置为 5 秒一样,我确实得到了提前超时,有些东西不允许它超过 1 分钟。
【问题讨论】:
标签: nginx websocket timeout proxypass