Edge origin protection
Keep the origin inside a separate trust boundary
The origin is the server behind the public edge. A CDN only protects the requests it handles. Limit origin network access to approved edge paths; use authenticated origin connectivity when available and validate certificates. Do not rely on a DNS name being secret. Prefer a private connection or narrowly scoped firewall policy and account-specific authentication: an IP allowlist of a shared provider network alone does not establish the identity of your distribution. The diagram is a desired policy, not a firewall command.
Public clients → public CDN endpoint → authenticated/private origin path → Nginx → appPublic clients → origin listener: denied at network boundaryManagement → separate authorized management pathSeparate transport peer from end-user identity
At the first trusted edge, replace untrusted forwarding metadata. If Nginx is behind an approved proxy, configure Real IP only for documented immediate trusted peers and the header that proxy actually sets. A downstream effective client address is not proof of an authenticated user. Network restrictions should operate on the transport peer before address rewriting; applying HTTP allow/deny after Real IP may instead evaluate the rewritten client. This example uses documentation-only CIDR, not actual provider ranges, and requires the Real IP module. Verify provider ranges and change procedures before deployment.
set_real_ip_from 192.0.2.0/24;real_ip_header X-Forwarded-For;real_ip_recursive on;Preserve identity deliberately at the application boundary
Use a fixed reviewed backend destination and define header ownership. In this example the first edge overwrites client forwarding information and uses its observed scheme. When TLS terminates at an earlier trusted hop, use a separately verified scheme policy rather than blindly replacing it with the local HTTP hop scheme. Restrict the backend to the proxy path and enforce authorization in the backend; a forwarding header does not grant access. This is a location fragment, not a full deployment.
proxy_pass http://127.0.0.1:19107;proxy_set_header Host backend.test;proxy_set_header X-Forwarded-For $remote_addr;proxy_set_header X-Forwarded-Proto $scheme;Choose edge caching and capacity boundaries
Cache public stable content at the CDN to reduce origin work, but do not cache account-specific responses without a verified safe policy. Bound origin timeouts, request size and connection budgets according to legitimate traffic. A CDN cache miss can still reach the origin; independent application quotas and isolation remain important. Keep a versioned origin access policy, certificate renewal and an approved rollback. This inert inventory identifies who owns each control.
{ "network": "platform-team", "edge-policy": "security-team", "origin": "sre-team", "resource-authorization": "application-team", "private-response-cache": "disabled"}Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Edge origin protection
Design a restricted origin boundary and trustworthy forwarding metadata behind an edge service.
What is a robust origin protection goal?
What does set_real_ip_from define?
Why distinguish network peer and effective client IP?
Which content is a safe default CDN cache candidate?
Who enforces per-resource authorization?