> For the complete documentation index, see [llms.txt](https://docs.appmixer.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.appmixer.com/connector-configuration/cloudflarewaf.md).

# Cloudflare WAF

Cloudflare WAF integrations allows you to actively block attacker IP by using Cloudflare WAF infrastructure.

### Authentication

Cloudflare WAF connector support authentication via Account API Token or User API Token

#### Account API Token

To create the Account API Token, go to the **Manage Accounts** > **Account API Tokens**, click on "Create Token". On the next screen, select the "Create Custom Token" option.

Name the token and select the permission:

* Account | Rule Rulesets | Edit

![Account API Token](https://802996127-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIAGKHlIqVKJe9agnFr14%2Fuploads%2Fgit-blob-3f091aa1a8dbe673e867c4120092a3b059d8de65%2Fcloudflarewaf_1.png?alt=media)

#### User API Token

To create the User API Token, go to the **Profile** > **API Tokens**, click on "Create Token". On the next screen, select the "Create Custom Token" option.

Name the token and select the permission:

* Account | Rule Rulesets | Edit

![User API Token](https://802996127-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FIAGKHlIqVKJe9agnFr14%2Fuploads%2Fgit-blob-bb3d663039ed37198ebcdaa8e88e3374ecafeea7%2Fcloudflarewaf_2.png?alt=media) In the Cloudflare connector authentication window, use your API Token to log in.

## Backoffice configuration

No Backoffice configuration is required. The connector reads optional keys that tune the **Block IPs** component and the background jobs that remove blocked IPs when their TTL expires.

Configuration ID: `appmixer:cloudflareWAF` (Backoffice → Configuration; see [Connector Configuration](https://docs.appmixer.com/getting-started/services) for how a configuration is created and how its keys reach the connector).

* `ipDeleteJobSchedule` — Optional. Cron schedule (with seconds) of the job that removes IPs whose TTL has expired from the WAF block rules. Default `*/10 * * * * *` (every 10 seconds).
* `ipDeleteJobLockTTL` — Optional. How long, in milliseconds, the delete job holds its lock so that only one instance runs at a time. Default `10000` (10 seconds).
* `cleanupJobSchedule` — Optional. Cron schedule (with seconds) of the job that drops stored IP records that could not be removed from the rules for more than 30 minutes. Default `0 0 * * * *` (every hour).
* `cleanupJobLockTTL` — Optional. How long, in milliseconds, the cleanup job holds its lock. Default `10000` (10 seconds).
* `generatedRuleNamePrefix` — Optional. Prefix of the description of the WAF rules the connector creates; a rule is named `<prefix>#<n>`. Default `Generated Rule`.
* `generatedRuleRefPrefix` — Optional. Prefix of the `ref` of the WAF rules the connector creates (`<prefix>#<n>`). The connector finds its own rules by this prefix, so rules created before you change it are no longer managed. Default `generated_rule`.
* `uploadLockRetryDelay` — Optional. **Block IPs** locks the zone while it updates the rules, so that several components writing to the same zone do not overwrite each other. This is the wait, in milliseconds, between attempts to get the lock. Default `5000` (5 seconds).
* `uploadLockTtl` — Optional. How long, in milliseconds, **Block IPs** may hold the zone lock. Default `900000` (15 minutes).
* `uploadLockMaxRetryCount` — Optional. How many times **Block IPs** tries to get the zone lock before it fails. Default `60`.

The same keys can be set with the CLI (`-u` updates the existing configuration instead of creating it):

```bash
appmixer service-config set appmixer:cloudflareWAF -u -d '{
  "ipDeleteJobSchedule": "*/10 * * * * *",
  "cleanupJobSchedule": "0 0 * * * *"
}'
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.appmixer.com/connector-configuration/cloudflarewaf.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
