feat(gitea): add Anubis anti-crawler proxy
Anubis (https://anubis.techaro.lol) is a lightweight proof-of-work challenge that protects web services from AI crawlers and scrapers.
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
{ ... }:
|
{ config, ... }:
|
||||||
|
|
||||||
let
|
let
|
||||||
srcDomain = "src.thehellings.com";
|
srcDomain = "src.thehellings.com";
|
||||||
@@ -6,15 +6,23 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
greg.proxies."${srcDomain}" = {
|
greg.proxies."${srcDomain}" = {
|
||||||
target = "https://gitea.shire-zebra.ts.net";
|
target = "http://unix:${config.services.anubis.instances.git.settings.BIND}";
|
||||||
ssl = true;
|
ssl = true;
|
||||||
genAliases = false;
|
genAliases = false;
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
proxy_ssl_verify off;
|
#proxy_ssl_verify off;
|
||||||
proxy_ssl_server_name on;
|
#proxy_ssl_server_name on;
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
proxy_set_header X-Forwarded-Ssl on;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Http-Version $server_protocol;
|
||||||
|
proxy_set_header User-Agent $http_user_agent;
|
||||||
client_max_body_size 100000m;
|
client_max_body_size 100000m;
|
||||||
|
|
||||||
|
#proxy_set_header Host $host;
|
||||||
|
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
#proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
#proxy_set_header X-Forwarded-Ssl on;
|
||||||
|
|
||||||
# Ultimate AI Block List v1.7 20250924
|
# Ultimate AI Block List v1.7 20250924
|
||||||
# https://perishablepress.com/ultimate-ai-block-list/
|
# https://perishablepress.com/ultimate-ai-block-list/
|
||||||
|
|
||||||
@@ -87,6 +95,44 @@ in
|
|||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [ sshPort ];
|
networking.firewall.allowedTCPPorts = [ sshPort ];
|
||||||
|
|
||||||
|
services = {
|
||||||
|
anubis = {
|
||||||
|
instances = {
|
||||||
|
git = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
BIND = "/run/anubis/anubis-git/anubis.sock";
|
||||||
|
COOKIE_DOMAIN = "thehellings.com";
|
||||||
|
SERVE_ROBOTS_TXT = true;
|
||||||
|
TARGET = "https://gitea.shire-zebra.ts.net/";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
haproxy = {
|
||||||
|
enable = true;
|
||||||
|
config = ''
|
||||||
|
global
|
||||||
|
daemon
|
||||||
|
maxconn 20
|
||||||
|
|
||||||
|
defaults
|
||||||
|
timeout connect 500s
|
||||||
|
timeout client 500s
|
||||||
|
timeout server 1h
|
||||||
|
|
||||||
|
listen gitsshd
|
||||||
|
bind *:${toString sshPort}
|
||||||
|
timeout client 1h
|
||||||
|
mode tcp
|
||||||
|
server git-isaiah isaiah.shire-zebra.ts.net:32222
|
||||||
|
server git-jeremiah jeremiah.shire-zebra.ts.net:32222
|
||||||
|
server git-zeke zeke.shire-zebra.ts.net:32222
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
systemd.services = {
|
systemd.services = {
|
||||||
haproxy = {
|
haproxy = {
|
||||||
after = [
|
after = [
|
||||||
@@ -98,25 +144,5 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
services.haproxy = {
|
users.users.nginx.extraGroups = [ config.users.groups.anubis.name ];
|
||||||
enable = true;
|
|
||||||
config = ''
|
|
||||||
global
|
|
||||||
daemon
|
|
||||||
maxconn 20
|
|
||||||
|
|
||||||
defaults
|
|
||||||
timeout connect 500s
|
|
||||||
timeout client 500s
|
|
||||||
timeout server 1h
|
|
||||||
|
|
||||||
listen gitsshd
|
|
||||||
bind *:${toString sshPort}
|
|
||||||
timeout client 1h
|
|
||||||
mode tcp
|
|
||||||
server git-isaiah isaiah.shire-zebra.ts.net:32222
|
|
||||||
server git-jeremiah jeremiah.shire-zebra.ts.net:32222
|
|
||||||
server git-zeke zeke.shire-zebra.ts.net:32222
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -119,6 +119,53 @@ spec:
|
|||||||
cpu: "100m"
|
cpu: "100m"
|
||||||
memory: "2Gi"
|
memory: "2Gi"
|
||||||
|
|
||||||
|
# Anubis anti-crawler sidecar
|
||||||
|
# Anubis listens on :8080 and proxies to Gitea at http://localhost:3000
|
||||||
|
# Ingress is updated to route to the anubis port instead of http
|
||||||
|
extraContainers:
|
||||||
|
- name: anubis
|
||||||
|
image: ghcr.io/techarohq/anubis:latest
|
||||||
|
imagePullPolicy: Always
|
||||||
|
env:
|
||||||
|
- name: BIND
|
||||||
|
value: ":8080"
|
||||||
|
- name: DIFFICULTY
|
||||||
|
value: "4"
|
||||||
|
- name: METRICS_BIND
|
||||||
|
value: ":9090"
|
||||||
|
- name: POLICY_FNAME
|
||||||
|
value: "/etc/anubis/policy.yaml"
|
||||||
|
- name: SERVE_ROBOTS_TXT
|
||||||
|
value: "true"
|
||||||
|
- name: TARGET
|
||||||
|
value: "http://localhost:3000"
|
||||||
|
volumeMounts:
|
||||||
|
- name: anubis-policy
|
||||||
|
mountPath: /etc/anubis
|
||||||
|
readOnly: true
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpu: "750m"
|
||||||
|
memory: "256Mi"
|
||||||
|
requests:
|
||||||
|
cpu: "250m"
|
||||||
|
memory: "256Mi"
|
||||||
|
securityContext:
|
||||||
|
runAsUser: 1000
|
||||||
|
runAsGroup: 1000
|
||||||
|
runAsNonRoot: true
|
||||||
|
allowPrivilegeEscalation: false
|
||||||
|
capabilities:
|
||||||
|
drop:
|
||||||
|
- ALL
|
||||||
|
seccompProfile:
|
||||||
|
type: RuntimeDefault
|
||||||
|
|
||||||
|
extraVolumes:
|
||||||
|
- name: anubis-policy
|
||||||
|
configMap:
|
||||||
|
name: anubis-policy
|
||||||
|
|
||||||
strategy:
|
strategy:
|
||||||
type: RollingUpdate
|
type: RollingUpdate
|
||||||
rollingUpdate:
|
rollingUpdate:
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ spec:
|
|||||||
storage: |-
|
storage: |-
|
||||||
MINIO_ACCESS_KEY_ID={{ .minio_nas1_key }}
|
MINIO_ACCESS_KEY_ID={{ .minio_nas1_key }}
|
||||||
MINIO_SECRET_ACCESS_KEY={{ .minio_nas1_secret }}
|
MINIO_SECRET_ACCESS_KEY={{ .minio_nas1_secret }}
|
||||||
minio_key: "{{ .minio_nas1_key }}"
|
#minio_key: "{{ .minio_nas1_key }}"
|
||||||
minio_secret: "{{ .minio_nas1_secret }}"
|
#minio_secret: "{{ .minio_nas1_secret }}"
|
||||||
secretStoreRef:
|
secretStoreRef:
|
||||||
name: bitwarden-login
|
name: bitwarden-login
|
||||||
kind: ClusterSecretStore
|
kind: ClusterSecretStore
|
||||||
|
|||||||
Reference in New Issue
Block a user