From f70a28f9d1a7c617cf5a3d6f666b492600b44a6c Mon Sep 17 00:00:00 2001 From: f Date: Tue, 10 Nov 2026 15:08:42 -0300 Subject: [PATCH] feat: anubis geoip --- .env.sample | 8 ++++++++ abra.sh | 2 +- anubis.yml.tmpl | 28 ++++++++++++++++++++++++++++ compose.anubis-geoip.yml | 10 ++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 compose.anubis-geoip.yml diff --git a/.env.sample b/.env.sample index e4e0f04..23c550e 100644 --- a/.env.sample +++ b/.env.sample @@ -236,6 +236,13 @@ WRITE_TIMEOUT=0s ## Anubis metrics #COMPOSE_FILE="$COMPOSE_FILE:compose.anubis-metrics.yml" +## Enable Anubis GeoIP detection +#COMPOSE_FILE="$COMPOSE_FILE:compose.anubis-geoip.yml" +# YAML list of blocked ASNs +#ANUBIS_GEOIP_BLOCKED_ASNS='[13335,136907,45102]' +# YAML list of blocked countries +#ANUBIS_GEOIP_BLOCKED_COUNTRIES='[BR,CN,VN]' + ## Enable onion service support #ONION_ENABLED=1 @@ -259,3 +266,4 @@ WRITE_TIMEOUT=0s #RATE_LIMIT_AVERAGE=100 #RATE_LIMIT_BURST=200 #RATE_LIMIT_PERIOD=1s + diff --git a/abra.sh b/abra.sh index 7370edf..becea47 100644 --- a/abra.sh +++ b/abra.sh @@ -1,4 +1,4 @@ export TRAEFIK_YML_VERSION=v37 export FILE_PROVIDER_YML_VERSION=v14 export ENTRYPOINT_VERSION=v5 -export ANUBIS_YML_VERSION=v1 +export ANUBIS_YML_VERSION=v2 diff --git a/anubis.yml.tmpl b/anubis.yml.tmpl index 7526aa9..f2867b4 100644 --- a/anubis.yml.tmpl +++ b/anubis.yml.tmpl @@ -1,7 +1,35 @@ bots: +{{ if eq (env "ANUBIS_GEOIP_ENABLED") "true" }} +{{ if ne (env "ANUBIS_GEOIP_BLOCKED_ASNS") "" }} +- name: blocked-asns + action: WEIGH + asns: + match: {{ env "ANUBIS_GEOIP_BLOCKED_ASNS" }} + weight: + adjust: 10 +{{ end }} +{{ if ne (env "ANUBIS_GEOIP_BLOCKED_COUNTRIES") "" }} +- name: countries-with-aggressive-scrapers + action: WEIGH + geoip: + countries: {{ env "ANUBIS_GEOIP_BLOCKED_COUNTRIES" }} + weight: + adjust: 10 +{{ end }} +{{ end }} - import: (data)/meta/default-config.yaml {{ if eq (env "ANUBIS_METRICS_ENABLED") "true" }} metrics: bind: ":9090" network: "tcp" {{ end }} +{{ if eq (env "ANUBIS_GEOIP_ENABLED") "true" }} +geoip: + asn: + path: /var/lib/anubis/GeoLite2-ASN.mmdb + country: + path: /var/lib/anubis/GeoLite2-Country.mmdb +logging: + sink: stdio + asn: true +{{ end }} diff --git a/compose.anubis-geoip.yml b/compose.anubis-geoip.yml new file mode 100644 index 0000000..8a11d9a --- /dev/null +++ b/compose.anubis-geoip.yml @@ -0,0 +1,10 @@ +--- +version: "3.8" +services: + anubis: + environment: + ANUBIS_GEOIP_ENABLED: "true" + volumes: + - "anubis-geoip:/var/lib/anubis/:ro" +volumes: + anubis-geoip: -- 2.54.0