Skip to content

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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

centinel-fastly/install
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

Verify
curl -i https://www.example.com/some-page

Expect 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

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.

  • 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.