Skip to content

Commit

Permalink
media-server: Ban all requests from robots
Browse files Browse the repository at this point in the history
  • Loading branch information
mohkale committed Jan 12, 2025
1 parent 3c102ca commit 628636f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions prog/media-server/proxy/Caddyfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ import /etc/caddy/local.d/Caddyfile.global
}
}

(ban_bots) {
# Adapted from https://darthvi.com/post/forbidden-for-robots/
@botForbidden header_regexp User-Agent "(?i)AdsBot-Google|Amazonbot|anthropic-ai|Applebot|Applebot-Extended|AwarioRssBot|AwarioSmartBot|Bytespider|CCBot|ChatGPT|ChatGPT-User|Claude-Web|ClaudeBot|cohere-ai|DataForSeoBot|Diffbot|FacebookBot|Google-Extended|GPTBot|ImagesiftBot|magpie-crawler|omgili|Omgilibot|peer39_crawler|PerplexityBot|YouBot"
handle @botForbidden {
import error_pages 403
}
}

(service_proxy_to) {
#(service, TLD, service_host, port)
http://{args[0]}.{args[1]} {
Expand All @@ -54,6 +62,8 @@ import /etc/caddy/local.d/Caddyfile.global
https://{args[0]}.{args[1]} {
# authorize with guests_policy
reverse_proxy {args[2]}:{args[3]}

import ban_bots
handle_errors 5xx {
import error_pages {err.status_code}
}
Expand All @@ -69,6 +79,8 @@ import /etc/caddy/local.d/Caddyfile.global
https://{args[0]}.{args[1]} {
import authelia_forward_auth {args[1]}
reverse_proxy {args[2]}:{args[3]}

import ban_bots
handle_errors 5xx {
import error_pages {err.status_code}
}
Expand Down

0 comments on commit 628636f

Please sign in to comment.