brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: nginx upstream max_fails and fail_timeout drop a dead backend automatically

Nginx
~/tips/tip-nginx-upstream-max-fails

upstream app {

Takes a failing backend out of rotation for a while and uses a spare server meanwhile.

Plain nginx has no active health checks, but passive ones cost two parameters per server line.

upstream app {
    server 10.0.0.11:8080 max_fails=3 fail_timeout=30s;
    server 10.0.0.13:8080 backup;
}

After max_fails failed attempts within fail_timeout, nginx treats the server as unavailable for the same fail_timeout period and then tries it again. A backup server only gets traffic when all the others are down. The check is passive: real requests have to fail first, and by default only connection errors and timeouts count. The defaults are one failure and ten seconds. Active probes are an nginx Plus feature.

Further reading: ngx_http_upstream_module: server

Going deeper: Guide: fix a 502 Bad Gateway in Nginx Proxy Manager, with a checklist that finds the cause

More Nginx tips sudo certbot --nginx -d example.com -d www.example.com /data/nginx/custom/server_redirect.conf map $http_upgrade $connection_upgrade { proxy_intercept_errors on; proxy_redirect http://localhost:3000/ /app/; All Nginx tips (50) All topics

Link