Search Sreeni's Insights

Filter by content type
cloud October 12, 2017 6 min read

Edge-first architecture - security and caching at the CDN / proxy

Edge-first architecture moves security and caching decisions toward Azure CDN or Cloudflare, reducing origin load while covering WAF, TLS, rate limits and origin protection.

Share:

Edge-first architecture - security and caching at the CDN or proxy

Every request reaching the origin application is consuming origin capacity, even when the request is a bot, an attack or a repeated public resource. A web server is becoming a poor place to perform every security and caching decision. If we move suitable work to the edge, the origin can focus on business operations and protected data.

In this article, we are going to see an edge-first architecture using Azure CDN or Cloudflare. We will cover WAF, DDoS protection, TLS termination, bot filtering, rate limiting, caching and the controls needed to lock the origin to edge traffic. We will discuss a practical example in an upcoming article, and refer to the 2016 CDN article and Cloudflare article for the earlier architecture discussion.

TL;DR Summary

  • The edge is the first security and performance boundary before the origin.
  • WAF, DDoS protection, TLS termination, bot filtering and rate limiting can stop or reduce traffic early.
  • Cache only safe responses and vary the cache by the inputs which change the result.
  • Azure CDN and Cloudflare provide different edge capabilities and operational models.
  • Lock the origin so it accepts traffic only from approved edge IP ranges or a private path.
  • Cloudflare Workers was recently announced, but it is still in beta and should not be treated as a general production platform.

Challenges

Untrusted traffic

Attackers, crawlers and badly behaved clients are reaching the same front door as valid users. If the origin is handling every request, a traffic spike is becoming an application outage.

Repeated content

Public images, scripts and safe reference responses are being requested repeatedly. Sending every request to the origin adds latency and cost while the answer is unchanged.

Origin exposure

An edge service is not protecting an origin if a client can discover and call the origin address directly. The origin must validate the path, host and source network, and sensitive APIs should still enforce application authorization.

What is edge-first architecture?

Edge-first architecture places security, routing and caching decisions as close as possible to the client, before traffic reaches the origin application.

In simple terms, the edge is the front liner. It blocks bad traffic, serves a safe cached response and forwards only the requests which need origin processing.

The following diagram depicts the edge vendor boundary and the protected origin.

Edge-first architecture
Edge-first architecture

The purple path is a valid cacheable request served at the edge. A cache miss or dynamic request is passing through the edge controls to the origin, while blocked traffic does not reach the application.

Why edge-first architecture is important?

Edge-first architecture is important because it is reducing work at the origin and adding controls before the application is reached. A WAF can reject known attack patterns, rate limiting can protect a client or endpoint, and a cache can respond without an origin round trip.

The edge is not a replacement for secure application code. Authentication, authorization and validation remain at the origin, and the cache must never share a response across users incorrectly.

Edge capabilities

CapabilityPurposeWatch out
WAFBlock common web attacksTune rules and handle false positives
DDoS protectionAbsorb or mitigate volumetric trafficConfirm service scope and limits
TLS terminationEncrypt client-to-edge trafficUse HTTPS from edge to origin too
Bot filteringSeparate crawlers and suspicious clientsDo not block useful search or partner bots accidentally
Rate limitingProtect endpoint or client capacityReturn and document HTTP 429
CachingServe safe repeated responsesVary by query, header and authorization

Azure CDN has Verizon and Akamai options, while Cloudflare provides CDN, security and edge controls through its network. Choose from geography, rules, support, origin integration, data requirements and team familiarity.

Selection criteria

Cacheability

Cache public static content and responses with a clear freshness rule. Do not cache private fund data by default. If a response varies by FundId, language, authorization or a feature setting, include that input in the cache key or bypass the cache.

Security boundary

Terminate TLS at the edge only when the origin connection is also protected. Configure WAF and rate rules from real traffic, then monitor blocked and allowed requests.

Origin lock

Use firewall rules, access restrictions or network controls so the origin accepts only approved edge IP ranges. Validate the host header and do not treat a client-supplied “came from edge” header as proof by itself.

Origin locking is also requiring an operational process. Edge IP ranges can change, certificates expire and a new origin may need an allow-list entry. Keep the rule in a reviewed deployment definition, monitor rejected origin requests and test failover before changing the network boundary.

Operational model

Azure CDN can fit an Azure-centric platform, while Cloudflare can fit a provider-independent edge strategy. In our case, choose the service which the team can configure, monitor and change without creating another operational blind spot.

Cloudflare Workers was recently announced and still in beta. Use it only for an explicitly accepted preview experiment, not as an assumption that arbitrary application code can run reliably at the edge.

Cache invalidation is part of the design, not only a deployment command. Define how a changed script, image or public response is becoming fresh, and keep a purge process which an operator can use without disabling the complete cache. A cache which cannot be invalidated is creating a correctness risk.

Request flow

  1. The client sends HTTPS to the edge.
  2. The edge checks DDoS and WAF rules.
  3. Bot filtering and rate limiting decide whether the request continues.
  4. A safe cache hit returns immediately.
  5. A miss is forwarded over HTTPS to the locked origin.
  6. The origin authenticates, authorizes and processes the request.
  7. The edge stores only a response which is explicitly cacheable.

For a dynamic fund request, the edge may still add value by terminating TLS, rejecting malformed traffic and applying a rate rule even when it is not caching the response. This is the contrast between edge security and edge caching: one can be useful without the other.

Must Do / Should / Don’t

Must Do

  • Must lock the origin to approved edge traffic.
  • Must use HTTPS from client to edge and edge to origin.
  • Must define cache keys and bypass rules for private data.
  • Must monitor cache hits, blocked requests, origin errors and latency.

Should

  • Should start with static assets and clearly public responses.
  • Should tune WAF rules with a review process.
  • Should use rate limits before expensive origin processing.

Don’t

  • Don’t assume the CDN is an authorization layer.
  • Don’t cache a response containing user-specific fund data without a safe key.
  • Don’t expose an origin IP and rely only on a secret header.
  • Don’t build production architecture around a beta edge function.

Wrap up

In this article, we have looked at edge-first architecture, WAF, DDoS protection, TLS, bot filtering, rate limiting, caching, origin locking and Azure CDN versus Cloudflare.

Thanks for reading this article. In the next article, I will walk you through Kubernetes on Azure with ACS, AKS preview and ACI.

Related Posts