ARTICLE - CDN & Network

How to Configure HTTPS on a CDN: Origin Protocols, Certificate Types, and Pitfalls

How do you configure HTTPS certificates after putting your site on a CDN? This guide explains edge vs origin certificates, the three origin protocols, free vs custom certificates, and five common pitfalls.

2026-08-12 16IDC Original

How to Configure HTTPS on a CDN: Origin Protocols, Certificate Types, and Pitfalls

Once a website is behind a CDN, HTTPS splits into two segments: user → CDN and CDN → origin. Many people only configure the first segment; the second is missing or misconfigured, causing broken pages and certificate errors. This article explains CDN certificate configuration clearly.

1. First, Distinguish the Two Segments and Two Certificate Roles

Behind a CDN, users no longer connect directly to your server — they connect to CDN edge nodes. So HTTPS involves two segments:

  • Edge node ↔ user: needs an "edge certificate";
  • Edge node ↔ origin server: involves the protocol and certificate used during "origin fetch".

Correspondingly, certificates play two roles:

  • Edge certificate: deployed on CDN nodes and shown to users. With a CDN-managed free certificate, the CDN usually obtains and manages it automatically;
  • Origin certificate: deployed on your server for the CDN to verify when fetching. If the origin has no certificate, choose HTTP origin fetch.

Mixing these two concepts up is the most common cause of misconfiguration. For how CDNs work overall, see How CDNs Work.

2. Origin Protocol: Which of the Three to Choose

The origin protocol decides how the "CDN → origin" segment connects. There are usually three modes:

Origin Protocol Meaning Pros Cons
HTTP CDN fetches origin in plaintext No certificate needed on origin; simple Middle segment not encrypted
HTTPS CDN fetches origin over encryption Fully encrypted end to end; most secure Origin must have a valid certificate
Follow Match whatever the user used Both segments consistent Easy to misconfigure

Selection advice: choose HTTP origin fetch for the simplest setup (traffic inside the CDN network is low risk); choose HTTPS origin fetch for a fully secure chain; "follow" is only recommended when you are sure the origin protocol matches the edge. For higher-security setups, see CDN and SSL/TLS Configuration Best Practices.

3. Free Certificate vs Custom Certificate

The edge certificate mainly has two sources:

1. Free certificate (CDN-managed): obtained and auto-renewed by the CDN provider — most CDNs offer one-click free certificates. Ideal for the vast majority of personal and small sites: zero cost and no renewal worry. For the general way to obtain free certificates, see Let's Encrypt Auto-Renewal.

2. Custom certificate (uploaded): upload a certificate you bought from a CA. Suitable when you need higher validation (OV/EV), a stronger corporate image, or specific brands/wildcards/multi-domain. How to choose certificate types: SSL Certificate Types Guide.

Comparison:

Aspect Free Certificate Custom Certificate
Cost 0 Annual fee
Renewal Automatic You manage it
Validation Usually DV Can be OV/EV
Best for Personal & small sites Enterprises, trust-sensitive sites

4. Configuration Steps (Typical CDN)

  1. Enable CDN acceleration: add your domain to the CDN and configure CNAME resolution — see Adding Your Website to a CDN;
  2. Enable HTTPS: turn on the "free certificate" or upload a custom one in the CDN console so the user-to-edge segment uses HTTPS;
  3. Configure origin: pick the origin protocol (beginners: start with HTTP) and fill in the correct origin address and port;
  4. Set up redirect: configure HTTP → HTTPS automatic redirect (301/308) to consolidate on 443;
  5. Verify: open the https domain in a browser to confirm the padlock, and use an online checker to confirm the certificate chain is complete.

5. Common Pitfalls and Troubleshooting

Pitfall 1: Certificate/domain mismatch. Users access www.example.com but the certificate is for example.com. Fix: ensure the certificate domain configured on the CDN exactly matches the access domain (including www).

Pitfall 2: Mixed content. The page is HTTPS but references HTTP images, scripts, or APIs, and the browser blocks them. Fix: switch all resources to https or relative paths.

Pitfall 3: Origin protocol doesn't match the origin. You chose HTTPS origin fetch but the origin has no certificate, so the CDN returns 502/525. Fix: confirm the origin's 443 certificate works, or switch back to HTTP origin fetch.

Pitfall 4: Incomplete certificate chain. The browser reports "certificate not trusted", usually because the intermediate certificate was omitted when uploading. Fix: concatenate the leaf, intermediate, and root certificates in order.

Pitfall 5: Stale certificate cached. After replacing a certificate, some regions still report errors, possibly due to edge or client caching. Fix: wait for propagation, or clear the browser cache and retry in an incognito window.

  • Do I have to use HTTPS origin fetch:No. HTTP origin fetch is low risk in a CDN context (the user-to-CDN segment is encrypted), and many production sites use it for simplicity. Consider HTTPS origin only for highly sensitive use cases like finance.
  • How long do CDN free certificates last:Usually around 90 days, auto-renewed by the CDN, so you barely notice expiration.
  • Does HTTPS origin fetch slow things down:There is a little extra handshake overhead, usually negligible. CDN-to-origin paths typically ride internal or high-quality networks.
  • Browser still errors after configuration — what now:Work through the pitfalls in order: domain match → certificate chain → mixed content → origin protocol → cache.

7. Summary

One line: CDN HTTPS has two segments — user-to-edge uses the edge certificate, edge-to-origin uses the origin protocol; beginners get the simplest setup with a free certificate plus HTTP origin fetch, then troubleshoot via certificate match, chain, and mixed content. To study CDN systematically, bookmark the CDN Network category.

Integration & Code Examples

Example 1: Inspect the edge certificate chain and protocol versions

HOST="www.example.com"
openssl s_client -connect "$HOST:443" -servername "$HOST" -showcerts < /dev/null 2>&1 \
  | grep -E "^( [0-9]+ s:|    i:|Verify return code|Protocol|Cipher)"
# Count the certificates in the chain: a single one means no intermediates
echo | openssl s_client -connect "$HOST:443" -servername "$HOST" -showcerts 2>/dev/null \
  | grep -c "BEGIN CERTIFICATE"
# Only 1.2 and 1.3 should work; 1.0 and 1.1 must be refused
for v in tls1_2 tls1_3; do
  printf '%-8s ' "$v"
  openssl s_client -"$v" -connect "$HOST:443" -servername "$HOST" \
    < /dev/null 2>&1 | grep -m1 -E "Protocol|handshake failure"
done

The chain should show a leaf plus intermediates; a single certificate with a non-zero verify code means the edge omits intermediates and older clients will fail.

Example 2: Separate the edge certificate from the origin certificate

EDGE="www.example.com"
EDGE_IP="${EDGE_IP:?set EDGE_IP}"
ORIGIN="origin.example.com"
# Client-facing certificate
echo | openssl s_client -connect "$EDGE:443" -servername "$EDGE" 2>/dev/null \
  | openssl x509 -noout -subject -issuer -dates
# Origin certificate: independent? about to expire?
echo | openssl s_client -connect "$ORIGIN:443" -servername "$ORIGIN" 2>/dev/null \
  | openssl x509 -noout -subject -issuer -dates
# Pin the origin IP but keep the CDN hostname as Host/SNI
curl -sI --resolve "$EDGE:443:$EDGE_IP" "https://$EDGE/" | head -n 1

Full (strict) requires a verifiable origin certificate; this output is the evidence for whether you can enable strict mode instead of rolling back after launch.

Four Checks: Edge Chain, Protocol Versions, Origin Certificate, and Redirects

Do not stop at the padlock in the browser. Verify four items in order: edge certificate chain, protocol versions, origin certificate, and the HTTP redirect. The first three can be checked from a shell, so you do not have to keep logging into the CDN console.

The chain check is about count and return code: the chain is complete only when both the leaf and the intermediate certificate are served, and a non-zero Verify return code means the edge is not sending the full chain, which older clients treat as a hard handshake failure.

Check Command or data source Pass condition What to inspect first
Edge chain openssl s_client -showcerts, then count BEGIN CERTIFICATE lines At least 2 certificates, Verify return code is 0 Missing intermediate in the uploaded file
Protocol versions Run openssl s_client -tls1_2 and -tls1_3 1.2 and 1.3 both handshake, 1.0/1.1 rejected Minimum TLS version set on the CDN
Origin certificate x509 -noout -subject -issuer -dates against origin port 443 Hostname matches and not expired Whether the origin serves a usable certificate
Origin reachability curl -sI --resolve "$EDGE:443:$EDGE_IP" First line is 200 or 30x Origin protocol and port if you see 502/525

A 502 or 525 on the origin leg usually means HTTPS origin fetch was selected but port 443 on the origin has no certificate. Either add the origin certificate before enabling Full (strict), or fall back to HTTP origin fetch and keep the client-facing HTTPS intact.

Order of Operations for Certificate Swap and Origin Protocol Change

Swap certificates in this order: upload and verify the new one, switch the edge certificate, then purge caches and wait for propagation. Doing it the other way round means that during the window when the old certificate is retired, visitors can hit a name mismatch.

When moving the origin leg from HTTP to HTTPS, confirm the origin chain on port 443 first, then the origin port and origin HOST, and only then switch to strict. Watch two signals afterwards: the count of 502/525 responses and the change in origin latency.

Redirect only once: send HTTP to HTTPS with a single 301/308. Stacking two hops in the same path makes mixed-content debugging much harder, because you cannot tell which hop dropped the query string.

Limitations

  • This article reflects public information as of 2026-08-12; terms, prices and quotas follow the provider's current published terms.
  • Third-party capability and limit statements follow their official documentation; no further commitment is implied here.
  • Licensing, filing and data-residency decisions must be verified against the regulations of your operating region.

FAQ

Which origin protocol is better for most sites?

Use HTTP origin fetching for most sites. The user-to-edge leg is already encrypted, and origin traffic runs over the CDN's internal network or dedicated lines, so exposure stays limited. Switch to HTTPS origin only when the origin holds a valid certificate and compliance demands end-to-end encryption; follow mode breaks most often when both ends disagree.

Do paid certificates cost more for real security?

Use free certificates for personal and small sites — they cost nothing and renew automatically on a roughly 90-day cycle. Paid ones bill annually and buy OV/EV validation levels, a specific brand, and wildcard coverage — not stronger encryption. Order OV/EV only when the certificate must display verified organizational details.

Why does origin fetching return 525?

Typically a 525 means the origin TLS handshake failed, so check port 443 on the origin first. Verify the certificate chain is complete, the domain matches, and nothing has expired, then confirm the CDN's origin protocol was not set to HTTPS by mistake; if the origin has no certificate at all, switch back to HTTP and it recovers.

When should you avoid HTTPS origin fetching?

Avoid it when the origin has no certificate or uses one signed by an internal CA. The CDN cannot validate a self-signed certificate and the handshake fails outright, so static, non-sensitive sites are simpler on HTTP. Only compliance demanding end-to-end encryption justifies HTTPS origin, and then the origin certificate must chain to a public CA.

Related Providers

  • Cloudflare: Use it when edge certificates and origin protocol must be proven on the free plan first.
  • Aliyun CDN: Use it when a custom certificate and forced HTTPS redirect are needed for a mainland origin.
  • AWS CloudFront: Use it when managed certificates must terminate TLS at the edge for an AWS origin.

Community & Resources

Official docs and communities

Learning resources and tools

Original source: 16IDC Original ↗