How to test
- clone the repo
- copy test-upstream conf to your nginx/openresty conf.d folder, and restart nginx/openresty
- in one pane:
node upstream.js 8800
- in another pane:
node upstream.js 8801
- in the last pane:
node client.js
8800 should be the one responding all the time
Then kill (Ctrl+C) the 8800 upstream, and see how fast it switches to 8801, without any 502
Then restart the 8800 upstream. It takes about 10 seconds for node to ok that the upstream is back. This is because of http://nginx.org/en/docs/http/ngx_http_upstream_module.html#fail_timeout