清漆 + nginx + ELB 499 响应 [英] Varnish + nginx + ELB 499 responses

查看:30
本文介绍了清漆 + nginx + ELB 499 响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 varnish 4 服务器与 nginx 一起用作连接到 ELB 的反向代理.

I am having varnish 4 server working with nginx as reverse proxy connected to ELB.

每 2 天左右我的服务器停止响应,我在 nginx access.log 中看到 499 个响应

Every 2 days or so my server is stop responding and I see 499 responses in nginx access.log

重启nginx即可解决问题.

restarting nginx is solving the problem.

为什么我开始收到这 499 条回复?

Why am I started to get these 499 responses?

为什么重启nginx解决问题?

Why restarting nginx solving the issue?

推荐答案

我在了解两个事实后解决了我的问题:

I solved my issue after understanding two facts:

1) ELB 实例具有动态 DNS 名称

1) ELB instance has dynamic DNS name

2) nginx 仅在重新加载/重启时解析 DNS 名称

2) nginx resolve DNS names only on reload/restart

问题是ELB改变了IP地址,nginx保留了原来的IP地址.

The problem was that the ELB changed its IP address and nginx kept the old IP address.

解决办法是在nginx.conf中使用resolver.这是我的 nginx.conf:

The solution is to use resolver in nginx.conf. Here is my nginx.conf:

http {  

    resolver x.x.x.x valid=30s;

}

server {

    set $elb "example.com";

    location / { 

        proxy_pass http://$elb; 

        }
}  

解析器 IP 地址应该是 DNS 服务器,例如/etc/resolv.conf 中.

The resolver IP address should be a DNS server such in /etc/resolv.conf.

这篇关于清漆 + nginx + ELB 499 响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆