feat: serve PAC file routing nyaa.si via browser-vpn-proxy
Some checks failed
validate / lint (push) Failing after 8s

Add a proxy-pac Argo CD Application: an nginx-unprivileged pod serving
http://proxy.home.arpa:8082/proxy.pac. The PAC sends nyaa.si and its
subdomains to the existing VLAN 50 SOCKS5 proxy (10.10.40.20:1080, which
resolves via Technitium's piracy-exempt group and egresses via PIA) with
no DIRECT fallback; everything else goes DIRECT. Intended for iOS, which
can't take a manual SOCKS proxy but honours SOCKS from a PAC.

Plain HTTP on a ServiceLB port because proxy.home.arpa already points at
10.10.40.20 in Technitium, while Traefik only answers on 10.10.40.53.
Port 8082 was checked free on all nodes; 8080 is taken on nik-debian.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nik Afiq 2026-11-17 23:05:48 +09:00
parent 02804118d4
commit b17eceb950
4 changed files with 212 additions and 0 deletions

View File

@ -66,6 +66,7 @@ Public services under `nik4nao.com` use Let's Encrypt.
| `https://nik4nao.com` | Portfolio | Let's Encrypt | | `https://nik4nao.com` | Portfolio | Let's Encrypt |
| `https://me.nik4nao.com` | me.nik4nao.com (terminal-style personal site) | Let's Encrypt | | `https://me.nik4nao.com` | me.nik4nao.com (terminal-style personal site) | Let's Encrypt |
| `http://ca.home.arpa` | Internal CA installer | Plain HTTP | | `http://ca.home.arpa` | Internal CA installer | Plain HTTP |
| `http://proxy.home.arpa:8082/proxy.pac` | PAC file: nyaa.si → browser-vpn-proxy (SOCKS5 `10.10.40.20:1080`), else DIRECT; see `manifests/proxy-pac/proxy-pac.yaml` header. `proxy.home.arpa` is defined in Technitium (`~/repo/home-network`), not Pi-hole | Plain HTTP |
`home.arpa` names are defined explicitly in `values/pihole.yaml` and `home.arpa` names are defined explicitly in `values/pihole.yaml` and
`values/pihole-debian.yaml`; Pi-hole is not configured as a wildcard DNS server. `values/pihole-debian.yaml`; Pi-hole is not configured as a wildcard DNS server.

View File

@ -0,0 +1,23 @@
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: proxy-pac
namespace: argocd
spec:
project: default
source:
repoURL: https://gitea.nik4nao.com/nik/homelab.git
targetRevision: main
path: manifests/proxy-pac
directory:
recurse: true
include: '*.yaml'
destination:
server: https://kubernetes.default.svc
namespace: proxy-pac
syncPolicy:
automated:
prune: false
selfHeal: true
syncOptions:
- CreateNamespace=true

View File

@ -20,6 +20,7 @@ subdirectories are consumed by Argo CD Applications in `argocd/apps`.
| `multus/` | Multus CNI, VLAN 50 NetworkAttachmentDefinition, canary, browser-vpn-proxy SOCKS5 proxy ([details](multus/README.md)) — manual-sync Application, see `argocd/apps/multus.yaml` | | `multus/` | Multus CNI, VLAN 50 NetworkAttachmentDefinition, canary, browser-vpn-proxy SOCKS5 proxy ([details](multus/README.md)) — manual-sync Application, see `argocd/apps/multus.yaml` |
| `network/` | Pi-hole secrets, DDNS, Traefik dashboard, external host ingresses | | `network/` | Pi-hole secrets, DDNS, Traefik dashboard, external host ingresses |
| `portfolio/` | Portfolio deployment, ingress, registry pull secret | | `portfolio/` | Portfolio deployment, ingress, registry pull secret |
| `proxy-pac/` | PAC file at `http://proxy.home.arpa:8082/proxy.pac` routing nyaa.si via browser-vpn-proxy (for iOS) |
## Secrets ## Secrets

View File

@ -0,0 +1,187 @@
# 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