A WAF attached to a distribution inspects every request to the distribution’s hostnames, at every location, before it reaches your origin. It’s the same WAF you attach to a load balancer: the same managed rule sets, custom rules, rate limits, log-only mode and request logs. A request it blocks never reaches your origin.
Before you start
- A WAF in the distribution’s project. See Create a WAF and attach it for writing one; leave it in log-only mode at first to see what it would block.
cdn.distributions.updateon the distribution andwaf.wafs.attachon the WAF.
Attach it
-
In the console, open the distribution and select Attach WAF in its WAF section, choose the WAF and save. With the CLI:
ezgh cdn distributions update cdn_k2m9x0a7qpe4 --waf waf_4k2m9x0a7qpeOn a new distribution, choose it in the WAF section of Create distribution, or
ezgh cdn distributions create … --waf waf_4k2m9x0a7qpe. -
The distribution’s WAF status is Applying (
deployingin the API) until every location inspects its requests, then Applied (active). Each location starts as soon as it’s ready.
Change WAF attaches another one in its place. A WAF can be attached to several distributions and load balancers; a distribution has at most one WAF.
What it inspects
- Every request to the distribution: its method, path, query, headers and cookies, and its client IP, country and AS number.
- The request body, when the request gives its length (
Content-Length) and it’s at most 16 KB. Larger bodies, bodies sent without a length and WebSocket upgrades are inspected on everything but the body, and reach your origin unchanged. - The path the visitor asked for: the WAF runs before rewrites, so rules match your public URLs.
A blocked request is answered 403 with a short page naming its request ID, which is also the
requestId of its log record. Requests to /cdn-cgi/ paths aren’t inspected.
Rate limits
A rate limit counts each client’s requests at each location separately, and each distribution separately: a WAF attached to two distributions counts their requests apart.
Request logs
With logging on, the WAF’s records land in its environment as they do for a load balancer, with
distributionId where a load balancer’s records have loadBalancerId and listenerId.
Detach it
Select Detach in the distribution’s WAF section, or:
ezgh cdn distributions update cdn_k2m9x0a7qpe4 --no-wafIts requests stop being inspected. The WAF stays in the project, and can’t be deleted while any distribution or load balancer has it.
With Terraform
resource "ezghcloud_cdn_distribution_waf" "web" {
project_id = var.project_id
distribution_id = ezghcloud_cdn_distribution.web.id
waf_id = ezghcloud_waf.web.id
}ezghcloud_cdn_distribution doesn’t manage the WAF, so the two never undo each other.
With the API
A create can attach one (CreateDistribution):
{
"name": "storefront",
"origin": { "host": "shop-lb.example.com", "port": 443, "protocol": "https", "hostHeader": "viewer" },
"waf": { "wafId": "waf_4k2m9x0a7qpe" }
}On an existing distribution, a replace (UpdateDistribution)
is the whole document: read the distribution, send back everything it has (its domains, rewrites,
tags and description included) with waf added, and If-Match set to the ETag of the
read. Anything you leave out takes its default, except waf: a replace that leaves waf out keeps
the attached WAF, so a client that doesn’t know the field never detaches it. "waf": null
detaches it.
The distribution’s waf shows wafId, status (deploying, active, or failed when a
location couldn’t apply the WAF’s latest version and keeps inspecting with the one it had) and
version, the WAF version status refers to.
Attaching is refused with 409 waf_mismatch for a WAF in another project or region, and 403
without waf.wafs.attach.
Pricing
$5.00 per distribution per month with a WAF attached, billed by the hour, plus Observability ingest for request logs. See WAF pricing.