0

Preface: I'm trying to implement Blue-Green Deployment.

With the following nginx.conf:

http {

    upstream backend {
        keepalive_timeout               65;

        server django_blue:8000 fail_timeout=5s max_fails=1;
        server django_green:8000 fail_timeout=5s max_fails=1;
    }

    server {
        listen 80 default_server;

        location / {
            proxy_pass              http://backend;
            proxy_redirect          off;
            proxy_set_header        Host $http_host;
            proxy_set_header        X-Real-IP $remote_addr;
            proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header        X-Forwarded-Host $host;
            proxy_set_header        X-Forwarded-Proto https;
            proxy_read_timeout      2s;
            client_max_body_size    20m;
        }
    }
}
  • If django_blue and django_green are both up & running all is working well: nginx does correctly LB in Roundrobin.

  • If I shutdown one of them - say django_green and then go on Chrome to do a web request, if the round robin gives the shutted down server, django_green, it waits for 1 minute (exactly 60 secs) and then reply to the browser with 504 Gateway Error.

So I've two questions:

  1. why it waits 1 mins and not fail_timeout value?
  2. why it don't simply reply with the another available server in upstream directive?

1 Answers1

0

I just figured it out, that's a proxy_connect_timeout issue.

So I've just added: proxy_connect_timeout 2s;

to location / {} block