CDN Returns 404 or the Default Site After Origin Host Changes? Check Host, SNI, and Virtual Hosts
Create Time:2026-11-17 10:06:31
浏览量
1105

CDN and browser traffic selecting the correct origin virtual host through Host and TLS SNI

After a CDN change, visitors may receive a 404, a certificate error, or the default website even though the public hostname is correct. The usual fault is a mismatch among the client-facing Host, the TLS SNI used during the origin handshake, and the name used by the origin virtual host.

A CDN may configure the origin address, HTTP Host header, TLS SNI, and certificate validation name as separate fields. They can have different defaults. Cache layers, redirects, and multiple origins can also make the failure appear only from some locations.

Identify the layer that generated the response

Record the full URL, client-visible status, response headers, CDN request ID, and timestamp. Separate these cases:

  • The CDN generated the error page at the edge.

  • The CDN reached the origin and the origin returned a 404 or default-site response.

  • The TLS handshake failed because the certificate or SNI did not match.

  • The origin returned the correct content, but an old error response remains cached.

Correlate CDN logs with load-balancer logs, web-server access logs, and error logs. If the origin has no matching request, check the origin address, network policy, and TLS path. If the request reached an unexpected server block, inspect Host matching and virtual-host order.

Separate the origin address, Host, and SNI

The origin address selects the IP or hostname to connect to. The HTTP Host header selects an application-level virtual host. TLS SNI helps the server select a certificate and TLS configuration during the handshake. Some providers also use a separate name for certificate validation.

Common mismatches include:

  • The origin IP belongs to a shared server, while Host still contains the CDN hostname.

  • Host was changed to an internal origin name, but SNI still uses the previous public name.

  • The certificate covers the visitor hostname but not the name used for the CDN-to-origin handshake.

  • Virtual-host and certificate configuration differs between origins.

  • A redirect exposes an internal origin hostname to visitors.

Check the provider documentation to determine which origin fields are independently configurable and what SNI defaults to for HTTPS origin connections. Do not infer behavior from a similar-looking console label.

Test the virtual host with an authorized origin request

The following command maps the public hostname to a selected origin IP while preserving the URL hostname for Host and TLS SNI. Replace the documentation address with an authorized origin address. Keep certificate verification enabled.

curl -sS --max-time 15 \
  --resolve www.example.com:443:192.0.2.10 \
  -D origin.headers -o origin.body \
  'https://www.example.com/healthz'

grep -Ei '^(HTTP/|location:|server:|content-type:|via:|age:)' origin.headers
sha256sum origin.body

Request the same path through the CDN and compare the status, Location header, body hash, certificate chain, and CDN tracing headers. If direct origin access is correct while the CDN request is wrong, inspect the configured origin Host, SNI, and certificate-validation name.

For an HTTP-only virtual-host test, you can send an explicit Host header, but this does not validate HTTPS SNI or certificates:

curl -sS --max-time 10 \
  -H 'Host: www.example.com' \
  -D origin-http.headers -o /dev/null \
  'http://192.0.2.10/healthz'

Check virtual-host and default-site configuration

Nginx, Apache, application gateways, and cloud load balancers may all select a backend by Host. Inspect listening ports, server names, certificate bindings, default sites, and rewrite rules on every origin. A matching configuration file does not prove that the same runtime configuration is loaded; use the service's configuration-test command and deployment record.

If the request reaches the default site, preserve its headers and body as evidence before changing the rule. Do not turn the default site into the business site to hide a Host mismatch. Unknown Host values should be rejected or handled explicitly.

All origins behind a load balancer need consistent virtual-host, certificate, and redirect behavior. Fixing only the currently healthy node leaves the same failure ready to return after the next routing change.

Verify both TLS legs and redirects

HTTPS involves two TLS connections: client to CDN and CDN to origin. Check each certificate's names, validity, chain, SNI selection, and validation policy separately. A certificate that looks correct to the client does not prove that the CDN can validate the origin certificate.

After a fix, use a controlled curl -v check or TLS diagnostic to record the selected certificate and protocol. Keep private hostnames, tokens, and internal addresses out of public tickets. Check every 301 and 302 Location value for the public hostname and intended scheme so an internal origin name is not returned and cached.

Purge narrowly and verify every backend

Save the before-and-after configuration, scope, and rollback plan. Invalidate only affected URLs or error responses where possible; a global purge can create an avoidable origin traffic spike. If the error response has a long freshness lifetime, check browser, CDN, and intermediary caches separately.

Request the affected path from representative networks and compare status, body hash, Location, Age, cache status, and response headers. Verify every origin returns the same version and that origin logs show the expected Host. One successful edge location does not prove that all paths are fixed.

References

These commands are controlled read-only examples and have not been run against your production environment. CDN defaults for origin Host, SNI, and certificate validation vary by provider; verify the deployed configuration and documentation.