Fix SSL on Nginx Proxy Manager and Caddy
SSL problems on a reverse proxy come from two TLS conversations confused for one: the browser to the proxy, and the proxy to the app. Nginx Proxy Manager and Caddy expose the fix in different places.
Start with the handshake, not the config
openssl s_client -connect example.com:443 -servername example.com -showcerts </dev/null 2>/dev/null | tail -8
Read the Verify return code. Zero means the chain is complete. Codes 20 and 21 mean a missing or invalid intermediate, which points at the proxy's certificate file rather than the app. If the handshake succeeds but the page redirects in a loop, the problem is headers, not TLS.
Redirect loops: the forwarded protocol
The proxy terminates TLS and forwards plain HTTP to the app. The app sees an insecure request, redirects to HTTPS, the proxy forwards plain HTTP again, and the browser loops. The fix is to tell the app it is behind a TLS-terminating proxy.
# Nginx proxy host
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
In Nginx Proxy Manager these headers are set for you on a standard proxy host. The loop usually appears when the app itself is configured to force HTTPS without trusting the forwarded header, or when the proxy and the app disagree about which one redirects. Pick one place to redirect, normally the proxy.
Nginx Proxy Manager SSL: the specifics
- HTTP-01 needs port 80. NPM validates through the proxy, so port 80 must be reachable from the internet. If it is closed, switch the certificate to a DNS challenge.
- DNS challenge needs an API token. NPM supports DNS providers through plugins. A wildcard certificate requires DNS-01; there is no other way.
- Two certificates, one hostname. If the app behind also serves a self-signed certificate, set the scheme to http in the proxy host rather than https, or enable the option to ignore the upstream certificate. Running Full (Strict) against a self-signed upstream produces 502 errors.
- Renewal failures. NPM renews on a schedule. If a challenge fails, the certificate expires and the panel shows the renewal error, which is easy to miss until the browser warns.
Nginx Proxy Manager and Caddy SSL: the Caddy specifics
Caddy obtains and renews certificates automatically as soon as a site block names a hostname. That is also why a broken Caddy setup is confusing: there is no certificate command to run, only DNS and ports to check.
example.com {
reverse_proxy 127.0.0.1:8080
}
Caddy sets X-Forwarded-Proto automatically, so redirect loops are rarer. When they happen, the app is usually forcing HTTPS on its own. For a wildcard or an internal-only hostname, configure the DNS challenge in the tls directive with your provider's plugin.
The four failures that account for most incidents
| Symptom | Cause | Fix |
|---|---|---|
| Browser warning, handshake fails | Expired or mismatched certificate on the proxy | Reissue and reload the proxy |
| Works in Chrome, fails in apps and cURL | Leaf served without the intermediate chain | Point the proxy at fullchain, not cert.pem |
| 502 Bad Gateway after enabling HTTPS upstream | Proxy validates a self-signed upstream certificate | Use http to the upstream, or install a trusted certificate there |
| Infinite redirect | App forces HTTPS without trusting X-Forwarded-Proto | Set the header, or stop the app redirecting |
Where the certificate should live
Put the publicly trusted certificate on the proxy, because that is the machine the browser talks to. Behind the proxy, either use plain HTTP on a private network or a certificate issued by your own internal authority. Do not copy the public certificate's private key onto every container; it multiplies exposure for no benefit.
Verify the result from outside with the SSL Checker, which reads the chain and SAN list the proxy actually serves. Then confirm the app is not adding a second redirect with the redirect chain checker.
Related reading: fixing redirect loops, free SSL on nginx, the record too long error and securing a GraphQL API with TLS.
Frequently Asked Questions
Can I run Let's Encrypt on both the proxy and the app?
You can, but the app's certificate must then be trusted by the proxy, which means installing your own authority or using a DNS-01 certificate for an internal name. Most setups do not need it.
Why does NPM fail the HTTP challenge behind Cloudflare?
Cloudflare answers the challenge at the edge instead of forwarding it. Set the record to DNS only during issuance, or use a DNS challenge.
Does Caddy need a cron job for renewal?
No. Caddy renews in the background and reloads itself. Watch the logs for renewal errors instead.
✅ 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
wwwversions resolve cleanly to one canonical HTTPS URL. - Verify your HTTPS property and
sitemap.xmlinside Google Search Console and Bing Webmaster Tools.