# Apply: kubectl apply -f manifests/proxy-pac/proxy-pac.yaml # Delete: kubectl delete -f manifests/proxy-pac/proxy-pac.yaml # Description: Proxy auto-config (PAC) file at http://proxy.home.arpa:8082/proxy.pac that sends nyaa.si (and subdomains) through browser-vpn-proxy (SOCKS5, 10.10.40.20:1080); everything else goes DIRECT. # # Why this exists: Technitium blocks piracy domains (hagezi # anti.piracy-onlydomains) for every subnet except VLAN 50. browser-vpn-proxy # lives on VLAN 50, resolves via Technitium from 10.10.50.12 (exempt group), # and egresses via PIA. Devices that can't take a manual SOCKS proxy for one # site only (iOS) point Wi-Fi -> Configure Proxy -> Automatic at this URL. # # Why plain HTTP on 10.10.40.20:8082 rather than HTTPS via Traefik: # proxy.home.arpa already resolves to 10.10.40.20 in Technitium # (~/repo/home-network/technitium/iac/main.tf), and Traefik is # externalTrafficPolicy: Local on minisforum (10.10.40.53) only, so it can't # answer for that name without repointing the existing record. Plain HTTP # also avoids a silent failure mode: iOS falls back to DIRECT if it can't # fetch the PAC (for example an untrusted internal CA). Port 8082 was checked # free on minisforum, nik-debian and nik-gpu on 2026-11-17 (`ss -tln` + pod # hostPorts); 8080 is NOT free, because a host process on nik-debian uses it. # ServiceLB binds 8082 on every node, so the URL works whether # proxy.home.arpa resolves to .20 (Technitium) or .53 (Pi-hole's home.arpa # catch-all). # # DNS for blocked names must happen on the proxy side. The PAC never calls # dnsResolve()/isResolvable(), and the client has to pass the hostname to the # SOCKS server. Test: the phone's own DNS returns NXDOMAIN for nyaa.si, so if # the page loads through this PAC, the proxy resolved it. If iOS ever turns # out to resolve locally, the fix is an HTTP CONNECT listener on the proxy # pod and a `PROXY` return, because CONNECT always carries the hostname. # # Editing the PAC: change proxy.pac below and push. The ConfigMap is mounted # as a directory (no subPath), so kubelet refreshes the file in about a minute # and nginx serves it without a restart. Changing nginx.conf needs # `kubectl -n proxy-pac rollout restart deploy/proxy-pac`. iOS caches the PAC; # toggle Wi-Fi off/on to refetch. --- apiVersion: v1 kind: Namespace metadata: name: proxy-pac --- apiVersion: v1 kind: ConfigMap metadata: name: proxy-pac namespace: proxy-pac data: proxy.pac: | // Served from manifests/proxy-pac/proxy-pac.yaml. Edit it there. function FindProxyForURL(url, host) { host = host.toLowerCase().replace(/\.$/, ""); if (host === "nyaa.si" || dnsDomainIs(host, ".nyaa.si")) { // SOCKS5 first, plain SOCKS for clients that only parse that // keyword. No DIRECT fallback: if the proxy is down, fail rather // than try the normal WAN. return "SOCKS5 10.10.40.20:1080; SOCKS 10.10.40.20:1080"; } return "DIRECT"; } nginx.conf: | worker_processes 1; pid /tmp/nginx.pid; error_log /dev/stderr warn; events { worker_connections 256; } http { access_log /dev/stdout; server_tokens off; client_body_temp_path /tmp/client_temp; proxy_temp_path /tmp/proxy_temp; fastcgi_temp_path /tmp/fastcgi_temp; uwsgi_temp_path /tmp/uwsgi_temp; scgi_temp_path /tmp/scgi_temp; server { listen 8080; root /etc/proxy-pac; location = /proxy.pac { default_type application/x-ns-proxy-autoconfig; add_header Cache-Control "no-cache" always; try_files /proxy.pac =404; } location = /healthz { access_log off; default_type text/plain; return 200 "ok\n"; } # Only the PAC is served. Never expose nginx.conf from the same dir. location / { return 404; } } } --- apiVersion: apps/v1 kind: Deployment metadata: name: proxy-pac namespace: proxy-pac labels: app: proxy-pac spec: replicas: 1 selector: matchLabels: app: proxy-pac template: metadata: labels: app: proxy-pac spec: automountServiceAccountToken: false securityContext: runAsNonRoot: true runAsUser: 101 runAsGroup: 101 seccompProfile: type: RuntimeDefault containers: - name: nginx image: "nginxinc/nginx-unprivileged@sha256:5d8bb9437d74a600ec5dbf90c035451c724dc33eac8d3a71078f6f8612c345f6" # 1.30.6-alpine-slim # Bypasses the image entrypoint scripts. They try to rewrite files # under /etc/nginx, which is read-only here. command: ["nginx", "-c", "/etc/proxy-pac/nginx.conf", "-g", "daemon off;"] ports: - name: http containerPort: 8080 readinessProbe: httpGet: path: /healthz port: http periodSeconds: 10 livenessProbe: httpGet: path: /healthz port: http initialDelaySeconds: 5 periodSeconds: 30 securityContext: allowPrivilegeEscalation: false readOnlyRootFilesystem: true capabilities: drop: ["ALL"] resources: requests: cpu: 5m memory: 16Mi limits: cpu: 100m memory: 64Mi volumeMounts: - name: config mountPath: /etc/proxy-pac readOnly: true - name: tmp mountPath: /tmp volumes: - name: config configMap: name: proxy-pac - name: tmp emptyDir: sizeLimit: 16Mi --- apiVersion: v1 kind: Service metadata: name: proxy-pac namespace: proxy-pac spec: selector: app: proxy-pac type: LoadBalancer # Reported IP only, as with browser-vpn-proxy / gitea-ssh: ServiceLB still # binds 8082 on every node (see header). loadBalancerIP: "10.10.40.20" ports: - name: http port: 8082 targetPort: http