1

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?

guyyug
  • 897
  • 1
  • 11
  • 23

1 Answers1

3

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.

guyyug
  • 897
  • 1
  • 11
  • 23
  • 1
    I don't understand this completely. What exactly are you doing in this configuration? – Abhyudit Jain Nov 06 '16 at 06:20
  • I set the elb address to a param and proxy_pass there. In addition, I set a resolver so this address will be up to date (with the right ip address) @AbhyuditJain – guyyug Nov 08 '16 at 12:42
  • if the ip address is changing then how do i set the ip? you are hard coding ip? – Abhyudit Jain Nov 09 '16 at 16:42
  • You don't set an ip. You set an hostname. – guyyug Nov 10 '16 at 16:12
  • @AbhyuditJain You should use the resolver param in the nginx.conf. Follow the instructions above above. – guyyug Nov 18 '16 at 20:28
  • I seem to be getting a similar issue but i am not sure whether it is the same. If you don't restart the nginx after two days all responses are 499 or just a few responses are 499 ? In my case I have few 499 in my nginx access log. Just wanted to confirm whether it is the same issue. – Sandeep Balagopal May 18 '20 at 12:48