Bot protection on Fastly VCL
Attach Centinel to your existing Fastly VCL service without changing your domains, origins, TLS certificates or custom VCL.
How it fits into Fastly
- Service footprint
- Three additions: a centinel backend, a private centinel_config Edge Dictionary and seven centinel_* VCL snippets.
- Timeouts and failure mode
- 1,000 ms connect, 3,000 ms first byte and 2,000 ms between bytes. Every validator failure fails open.
- Kill-switch
- Set enabled to "false" in centinel_config to bypass validation within seconds, with no version activation.
- Install paths
- The attach.sh script, manual setup in the Fastly web interface, or blocks in your fastly_service_vcl Terraform resource.
How a request moves through Fastly
The snippets run inside your own service, and the validator is a normal Fastly backend, so there is no second service in the path.
vcl_recv at priority 10
centinel_recv checks the kill-switch and the static-asset regex. Static assets, FASTLYPURGE, WebSocket upgrades, ESI subrequests, background fetches and shield passes skip validation.
Validator leg
The request restarts once toward the centinel backend as a bodyless POST /validate, marked x-sigsci-no-inspection: true so Next-Gen WAF skips it.
Decision
Allow restarts the original request to your origin with X-CN-Done: 1. Block and challenge serve the validator's page as a synthetic response.
vcl_deliver at priority 150
centinel_deliver sets the _centinel cookie and appends Server-Timing: centinel;dur=<ms>. A validator failure at any step sends the request to your origin.
Minimal configuration and a live check
Attach to an existing service
export FASTLY_API_KEY="your-fastly-api-token"
export CENTINEL_API_KEY="your-centinel-secret-key"
./attach.sh install <SERVICE_ID> --no-activate
./attach.sh status <SERVICE_ID>--no-activate leaves the cloned version as a draft, so you can review the backend, dictionary and snippets in the Fastly UI before you activate.
Check the cookie and timing header
curl -i https://www.example.com/some-pageExpect your normal origin response plus Set-Cookie: _centinel=... and Server-Timing: centinel;dur=<ms>. For the decision itself, set debug to true in centinel_config, look for x-centinel-decision, then set it back to false.
Deployment options
Attach script or Fastly web interface
Run ./attach.sh install <SERVICE_ID> to clone your active version, add the three components, validate the VCL and activate. The same steps work by hand in the Fastly UI.
Attach script and web interface guide (opens in a new tab)Terraform-managed services
Paste the centinel backend, the centinel_config dictionary and a dynamic snippet block into your existing fastly_service_vcl resource, with the seven .vcl files next to your config.
Terraform tab in the Fastly guide (opens in a new tab)
What to know before deploying
Never return() from a snippet below priority 10
It runs before centinel_recv and silently bypasses protection. Give a deliver snippet a priority above 150 if it must run after Centinel's cleanup.
The static-asset regex is a literal in recv.vcl
Fastly VCL cannot read a regex from a variable. To change what is skipped, edit the regex in recv.vcl and re-upload that one snippet.
Terraform cannot read write_only dictionary items
Populate secret_key, debug and enabled through the Fastly API after terraform apply, or manage the items with write_only = false.
Install stops on a name clash
The attach script aborts if any centinel_* name already exists on the service, and ./attach.sh uninstall removes only those names.
What stays untouched
- Your Fastly domains, TLS certificates and origin hosts
- Your custom VCL and non-Centinel snippets
- Your cache keys, shielding and purge workflows
- Your Next-Gen WAF rules at their default priority
Fastly integration questions
Walk through your Fastly setup
Bring one route bots are hitting. We will map the right connector, timeouts, and log-only rollout for your Fastly stack.