【问题标题】:Nginx throws 502 bad gateway sometimes with upstream as Amazon ELBNginx 有时会在上游作为 Amazon ELB 时抛出 502 bad gateway
【发布时间】:2018-05-26 20:40:50
【问题描述】:

ELB 动态地向上和向下扩展,因此 ELB 可能会在不同时间解析到不同的 IP 集。 Nginx 缓存上游目标的 IP,因此它不需要一次又一次地解析主机名。但是当上游 ELB 的 IP 发生变化(即一些旧 IP 不再是 ELB 的一部分)时,我们会遇到问题,因为 Nginx 继续将流量转发到不再附加任何目标的旧 IP。因此,该 IP(VM 或其他)会抛出 502 或错误网关,Nginx 也会向客户端返回相同的 502 状态。由于 Nginx 不遵守 dns 记录的 TTL,我们可能会遇到这个问题。

有没有人遇到过类似的问题,如果有,他们尝试过的解决方法是什么。

【问题讨论】:

标签: nginx amazon-elb ttl bad-gateway


【解决方案1】:

这是许多其他客户的已知问题。这可以通过使 Nginx 的缓存无效以查看上游 ELB 的 IP 是否更改来解决。我们可以在 Nginx 中使用解析器指令。 参考 - https://gc-taylor.com/blog/2011/11/10/nginx-aws-elb-name-resolution-resolvers , https://distinctplace.com/2017/04/19/nginx-resolver-explained/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-11-12
    • 2020-08-01
    • 2014-10-17
    • 2017-05-03
    • 2015-11-02
    • 2018-08-09
    • 2017-12-30
    相关资源
    最近更新 更多