ssl-guides 2026-12-02 ⏱ 3 min read

Configure SSL on HAProxy: Step by Step

Configure SSL on HAProxy: Step by Step

HAProxy is a natural place to terminate SSL: one point handles certificates for every backend, and renewals touch a single file. The configuration is small, but two details trip everyone up, the combined PEM format and the reload behavior. This guide covers both, plus a production-ready TLS setup.

HAProxy SSL setup: build the combined PEM file

HAProxy wants the certificate, intermediates, and private key in one file, in that order:

cat fullchain.pem privkey.pem > /etc/haproxy/certs/example.com.pem

Certificates from Let's Encrypt or TryFreeSSL already include a fullchain file, so the command is a simple concatenation. Restrict permissions, because the file holds your private key:

chmod 600 /etc/haproxy/certs/example.com.pem

The HTTP frontend: redirect everything

frontend http_in
    bind *:80
    mode http
    http-request redirect scheme https code 301

Every HTTP request gets a single permanent redirect to the same path over HTTPS. That one line handles the whole site; for other servers, generate the equivalent rule with the HTTPS Redirect Generator.

The HAProxy SSL frontend

frontend https_in
    bind *:443 ssl crt /etc/haproxy/certs/example.com.pem alpn h2,http/1.1
    mode http
    default_backend app_servers

backend app_servers
    mode http
    server app1 127.0.0.1:8000 check

The alpn h2,http/1.1 setting enables HTTP/2 for browsers that support it. For multiple certificates, point crt at a directory and HAProxy picks the right one by SNI.

Modern TLS settings for HAProxy SSL

Restrict the frontend to current protocols and let clients pick the cipher order:

frontend https_in
    bind *:443 ssl crt /etc/haproxy/certs/ alpn h2,http/1.1 ssl-min-ver TLSv1.2

TLS 1.2 and 1.3 are the only versions you should accept today. After reloading, confirm the negotiated versions and the chain with the SSL Checker and review HSTS and related headers with the Security Headers Checker.

Reload without dropping connections

HAProxy reloads are graceful when you ask for them. Always validate the config first, then reload:

haproxy -c -f /etc/haproxy/haproxy.cfg
systemctl reload haproxy

For certificate renewals, replace the PEM file and reload. Certbot deploy hooks can automate exactly this: concatenate the new files, then reload the service, so renewals never need a human. With shorter lifetimes coming (Let's Encrypt moves to 64 days on 10 February 2027, per its Let's Encrypt announcement), make the hook part of every setup.

Troubleshooting the common failures

  • HAProxy fails to start on the PEM file. The order is wrong or the key does not match the certificate. Leaf first, then intermediates, then the key.
  • Browsers warn about an untrusted chain. You concatenated only the leaf certificate. Use the fullchain file so intermediates are included.
  • HTTP/2 does not negotiate. The alpn token is missing from the bind line.
  • Renewals do not take effect. The PEM was updated but HAProxy was never reloaded; it keeps the old certificate in memory.

Related reading: the best TLS configuration and installing free SSL on Nginx.

Frequently Asked Questions

Can HAProxy pass SSL through without terminating it?

Yes, with a TCP-mode frontend and no ssl bind option. You lose layer-7 features like redirects and header rules, so termination is preferred unless the backend must see the original TLS session.

How do I serve several domains from one HAProxy?

Point crt at a directory containing one PEM per domain. HAProxy selects the certificate by SNI, and each domain gets its own backend through ACLs.

Does HAProxy handle OCSP stapling?

Yes. Place the OCSP response next to the PEM as example.com.pem.ocsp and HAProxy serves it. Your ACME client or a cron job should refresh the response regularly. This only matters for certificates that list an OCSP responder. Let's Encrypt certificates have not since 7 May 2025 (Let's Encrypt OCSP announcement), so you can skip it with them.

What TLS version should backends use?

If HAProxy re-encrypts to backends, TLS 1.2 or 1.3 there too. On a trusted private network, plain HTTP to backends is common and acceptable, and it simplifies backend configuration.

🔒 Test Your Website SSL Certificate Now
Run Free SSL Check →

✅ Post-Installation Verification & SEO Checklist

After applying the steps above, run through this 5-point checklist to prevent browser warnings and protect your Google SEO rankings:

  • Verify full CA chain trust and TLS 1.3 support using our Live SSL Checker.
  • Scan for Mixed Content HTTP links and check HSTS/CSP headers on Security Headers Checker.
  • Enforce a permanent 301 HTTP-to-HTTPS redirect with our HTTPS Redirect Generator.
  • Confirm both root and www versions resolve cleanly to one canonical HTTPS URL.
  • Verify your HTTPS property and sitemap.xml inside Google Search Console and Bing Webmaster Tools.
Technically Reviewed by TryFreeSSL Security Team
Last updated: 2026-12-05
About Us →

Free SSL Certificates, Live SSL Checker & CSR Generator

Issue trusted Let's Encrypt SSL certificates in 60 seconds with zero server setup.

Related Articles

🤖 TryFreeSSL AI Assistant