Course contentsShow
← Cloud and Infrastructure
Lesson 599 of 2,98911. CDN and Edge ComputingFree lesson

Custom Headers and Origin Requests

Add or modify HTTP headers in requests sent to origins for authentication or routing purposes.

Custom Headers and Origin Requests

What you'll learn: How to add or modify HTTP headers in requests your CDN sends to origin servers for authentication, routing, and control purposes.


When your CDN forwards a request to your origin server (the backend hosting your actual content), you often need to include extra information beyond what the visitor's browser sent. Custom headers let you inject additional HTTP headers into origin requests, enabling authentication, routing logic, or contextual data your application needs.

Why Add Custom Headers?

Think of custom headers like attaching sticky notes to each package before it's sent to your warehouse. These notes tell your warehouse workers how to handle the request differently.

Common use cases include:

  • Authentication: Adding a secret API key (e.g., X-API-Key: secret123) so your origin only accepts requests from your CDN, not the public internet
  • Routing: Sending a X-Origin-Region: us-west header to help your origin route to the correct backend service
  • Context: Passing metadata like X-CDN-POP: london to track which edge location handled the request
  • Protocol hints: Indicating the original visitor's protocol with X-Forwarded-Proto: https

How It Works

In your CDN configuration, you specify which headers to add or modify before the request leaves the edge server. Your origin application can then read these headers and act accordingly—validating credentials, logging analytics, or customizing responses.

For example, you might configure: "Always add X-Custom-Auth: Bearer mytoken to every origin request." Your origin checks for this header and rejects requests without it, securing your backend from direct access.

Key Takeaway:
Custom headers in origin requests let you authenticate, route, and pass contextual data from your CDN to your backend servers, enabling secure and intelligent content delivery workflows.