How to Handle SSL Certificates in a Load-Balanced Environment

When traffic is distributed across multiple servers, SSL certificate management needs coordination — ensuring every backend server has a consistent, current certificate, or centralizing TLS termination at the load balancer itself.

Two Main Architectural Approaches

TLS Termination at the Load Balancer — the load balancer handles HTTPS, communicating with backend servers over plain HTTP internally.
TLS Passthrough / End-to-End Encryption — each backend server handles its own TLS, with the load balancer passing encrypted traffic through unmodified.

Approach 1 — TLS Termination at the Load Balancer (Simpler, Common)

upstream backend_servers {
    server 10.0.0.10:80;
    server 10.0.0.11:80;
}

server {
    listen 443 ssl;
    server_name yourdomain.com;

    ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;

    location / {
        proxy_pass http://backend_servers;
        proxy_set_header X-Forwarded-Proto https;
    }
}

Only the load balancer needs a certificate — simplifies renewal and management significantly, since there's a single certificate to maintain rather than one per backend server.

Important: Internal Traffic Is Unencrypted

With this approach, traffic between the load balancer and backend servers travels as plain HTTP — acceptable if this traffic stays within a trusted private network, but ensure it's genuinely isolated (private network/VPC, not traversing the public internet unencrypted).

Approach 2 — TLS Passthrough (End-to-End Encryption)

stream {
    upstream backend_ssl {
        server 10.0.0.10:443;
        server 10.0.0.11:443;
    }

    server {
        listen 443;
        proxy_pass backend_ssl;
    }
}

Each backend server needs its own valid certificate for the domain — more complex to manage (certificate renewal must be coordinated across all backends) but maintains encryption for the entire path.

Synchronizing Certificates Across Multiple Backend Servers

If using per-server certificates, options include: a shared/synced certificate directory, a centralized certificate management tool distributing renewed certificates automatically, or a DNS-01 challenge-based renewal process run from one central location that then distributes the resulting certificate.

Using DNS-01 Validation for Coordinated Renewal

See How to Install a Wildcard SSL Certificate with Certbot DNS Challenge — DNS-01 validation doesn't require the challenge to be served from each specific backend server, simplifying renewal coordination in a multi-server setup.

Health Checks and Certificate Validity

Ensure your load balancer's health checks would actually catch a backend server serving an expired or misconfigured certificate (relevant specifically for the passthrough approach), preventing traffic from being routed to a broken backend.

Choosing the Right Approach for Your Situation

FactorTermination at LBPassthrough
Certificate management complexitySimple — one certificateMore complex — per-backend coordination
Internal traffic encryptionUnencrypted (relies on network isolation)Fully encrypted end-to-end
Common use caseMost general web applicationsCompliance-sensitive environments requiring end-to-end encryption

Common Errors

Backend server certificate expires independently, causing intermittent errors — a symptom of uncoordinated renewal across multiple backends in a passthrough setup; centralize the renewal and distribution process.

Continue Reading

Browse more articles in SSL/TLS & Certificates.

  • load balancer ssl, tls termination, ssl passthrough, multi server certificate management
  • 0 Пользователи нашли это полезным
Помог ли вам данный ответ?

Связанные статьи

How to Install Let's Encrypt SSL with Certbot (Nginx & Apache)

Let's Encrypt provides free, automated SSL/TLS certificates trusted by all major browsers....

HTTP to HTTPS Redirect: Forcing SSL on Nginx & Apache

Once SSL is installed, visitors reaching your site over plain HTTP should be automatically...

How to Renew and Auto-Renew Let's Encrypt Certificates

Let's Encrypt certificates are valid for only 90 days by design, to limit the impact of a...

How to Install a Wildcard SSL Certificate with Certbot DNS Challenge

A wildcard certificate secures a domain and all of its subdomains (*.example.com) with a single...

Common SSL Certificate Errors and How to Fix Them

SSL/TLS errors block visitors from accessing your site securely and can be caused by several...