feat(docs): add documentation for default allow behavior (#346)

This commit is contained in:
Luciano Hillcoat - lucdev.net 2025-04-23 22:13:21 -03:00 committed by GitHub
parent cfbe16f2d0
commit 2320ef4014
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 94 additions and 1 deletions

View file

@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
- Add documentation for default allow behavior (implicit rule)
- Enable [importing configuration snippets](./admin/configuration/import.mdx) ([#321](https://github.com/TecharoHQ/anubis/pull/321))
- Refactor check logic to be more generic and work on a Checker type
- Add more AI user agents based on the [ai.robots.txt](https://github.com/ai-robots-txt/ai.robots.txt) project

View file

@ -0,0 +1,92 @@
---
title: Default allow behavior
---
import Tabs from "@theme/Tabs";
import TabItem from "@theme/TabItem";
# Default allow behavior
Anubis is designed to be as unintrusive as possible to your existing infrastructure.
By default, it allows all traffic unless a request matches a rule that explicitly denies or challenges it.
Only requests matching a DENY or CHALLENGE rule are blocked or challenged. All other requests are allowed. This is called "the implicit rule".
## Example: Minimal policy
If your policy only blocks a specific bot, all other requests will be allowed:
<Tabs>
<TabItem value="json" label="JSON" default>
```json
{
"bots": [
{
"name": "block-amazonbot",
"user_agent_regex": "Amazonbot",
"action": "DENY"
}
]
}
```
</TabItem>
<TabItem value="yaml" label="YAML">
```yaml
- name: block-amazonbot
user_agent_regex: Amazonbot
action: DENY
```
</TabItem>
</Tabs>
## How to deny by default
If you want to deny all traffic except what you explicitly allow, add a catch-all deny rule at the end of your policy list. Make sure to add ALLOW rules for any traffic you want to permit before this rule.
<Tabs>
<TabItem value="json" label="JSON" default>
```json
{
"bots": [
{
"name": "allow-goodbot",
"user_agent_regex": "GoodBot",
"action": "ALLOW"
},
{
"name": "catch-all-deny",
"path_regex": ".*",
"action": "DENY"
}
]
}
```
</TabItem>
<TabItem value="yaml" label="YAML">
```yaml
- name: allow-goodbot
user_agent_regex: GoodBot
action: ALLOW
- name: catch-all-deny
path_regex: .*
action: DENY
```
</TabItem>
</Tabs>
## Final remarks
- Rules are evaluated in order; the first match wins.
- The implicit allow rule is always last and cannot be removed.
- Use your logs to monitor what traffic is being allowed by default.
See [Policy Definitions](./policies) for more details on writing rules.

View file

@ -112,7 +112,7 @@ bots:
This allows requests to [`/.well-known`](https://en.wikipedia.org/wiki/Well-known_URI), `/favicon.ico`, `/robots.txt`, and challenges any request that has the word `Mozilla` in its User-Agent string. The [default policy file](https://github.com/TecharoHQ/anubis/blob/main/data/botPolicies.json) is a bit more cohesive, but this should be more than enough for most users.
If no rules match the request, it is allowed through.
If no rules match the request, it is allowed through. For more details on this default behavior and its implications, see [Default allow behavior](./default-allow-behavior.mdx).
## Writing your own rules