Varnish + nginx + ELB 499 responses

我怕爱的太早我们不能终老 提交于 2019-12-03 23:03:40

问题


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

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

restarting nginx is solving the problem.

Why am I started to get these 499 responses?

Why restarting nginx solving the issue?


回答1:


I solved my issue after understanding two facts:

1) ELB instance has dynamic DNS name

2) nginx resolve DNS names only on reload/restart

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

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; 

        }
}  

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



来源:https://stackoverflow.com/questions/40200938/varnish-nginx-elb-499-responses

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!