---
title: "Discussion on \"NGINX Load Balancing, Failover & TLS on a VPS\" | Hashnode"
description: "Discussion on \"NGINX Load Balancing, Failover & TLS on a VPS\". Using the tools of titans"
url: "https://hashnode.com/posts/nginx-load-balancing-failover-tls-on-a-vps/699f84fac9015c37f6c80b9d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [NGINX Load Balancing, Failover & TLS on a VPS](https://bustamam.hashnode.dev/nginx-load-balancing-failover-tls-on-a-vps?utm_source=hashnode&utm_medium=feed)

Using the tools of titans

Feb 25 · 20 min read · bustamam.hashnode.dev  
Read the article

-   [#nginx](https://hashnode.com/tag/nginx)
-   [#web-development](https://hashnode.com/tag/web-development)
-   [#scalability](https://hashnode.com/tag/scalability)
-   [#caddy](https://hashnode.com/tag/caddy)

## Written by

[Rasheed Bustamam](https://hashnode.com/@abustamam)

@abustamam · Sacramento, California

  
[View profile](https://hashnode.com/@abustamam)

AI Native Engineer

Systems engineering, front end

## Responses 1

Markdown supported · ⌘↵ to post

[CDN Edge Ops](https://hashnode.com/@cdnedgeops)

[Oct 31](https://hashnode.com/posts/nginx-load-balancing-failover-tls-on-a-vps/699f84fac9015c37f6c80b9d/comment/6ae5782e6a46d6ec3a2917cf)

Migrating an L7 balancer from another reverse proxy into nginx is mostly about making failover honest. I pin an upstream with max\_fails and fail\_timeout that match real probe latency, enable proxy\_next\_upstream only for error/timeout on safe methods, and keep proxy\_read\_timeout shorter than the client-facing timeout so a hung peer leaves the pool before users see a blank spinner. Round-robin is fine until replica sizes diverge; then least\_conn plus equal weight beats ip\_hash for NAT-heavy offices.

On the TLS side I terminate once at nginx, push X-Forwarded-Proto and Host downstream, and reload only after nginx -t so a bad cert path never takes the whole edge offline. After cutover I hit each upstream directly, then through the LB, comparing status and upstream response time while I force one peer down — if 502s spike instead of clean failover, fail\_timeout is too long or next\_upstream is retrying POSTs. Log $upstream\_addr and $upstream\_status together for a week before trusting the pool in production.
