diff --git a/hosts/unstable/linode/git.nix b/hosts/unstable/linode/git.nix index 6bd2196..c7f5b65 100644 --- a/hosts/unstable/linode/git.nix +++ b/hosts/unstable/linode/git.nix @@ -1,4 +1,4 @@ -{ ... }: +{ config, ... }: let srcDomain = "src.thehellings.com"; @@ -6,15 +6,23 @@ let in { greg.proxies."${srcDomain}" = { - target = "https://gitea.shire-zebra.ts.net"; + target = "http://unix:${config.services.anubis.instances.git.settings.BIND}"; ssl = true; genAliases = false; extraConfig = '' - proxy_ssl_verify off; - proxy_ssl_server_name on; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_set_header X-Forwarded-Ssl on; + #proxy_ssl_verify off; + #proxy_ssl_server_name 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; + + #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 # https://perishablepress.com/ultimate-ai-block-list/ @@ -87,6 +95,44 @@ in 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 = { haproxy = { after = [ @@ -98,25 +144,5 @@ in }; }; - services.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 - ''; - }; + users.users.nginx.extraGroups = [ config.users.groups.anubis.name ]; } diff --git a/manifests/gitea/chart.yaml b/manifests/gitea/chart.yaml index 9aa3a56..de28e61 100644 --- a/manifests/gitea/chart.yaml +++ b/manifests/gitea/chart.yaml @@ -119,6 +119,53 @@ spec: cpu: "100m" 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: type: RollingUpdate rollingUpdate: diff --git a/manifests/gitea/secrets.yaml b/manifests/gitea/secrets.yaml index 25b028a..f0117bd 100644 --- a/manifests/gitea/secrets.yaml +++ b/manifests/gitea/secrets.yaml @@ -15,8 +15,8 @@ spec: storage: |- MINIO_ACCESS_KEY_ID={{ .minio_nas1_key }} MINIO_SECRET_ACCESS_KEY={{ .minio_nas1_secret }} - minio_key: "{{ .minio_nas1_key }}" - minio_secret: "{{ .minio_nas1_secret }}" + #minio_key: "{{ .minio_nas1_key }}" + #minio_secret: "{{ .minio_nas1_secret }}" secretStoreRef: name: bitwarden-login kind: ClusterSecretStore