# frp-mtls.conf — nginx :8470 TLS-termination + device-CA mTLS + WS-upgrade proxy to frps vhost. # # Native mTLS tunnel · V4. Install target: /etc/nginx/conf.d/frp-mtls.conf # This is a conf.d snippet (safe to ADD — it only introduces a NEW loopback :8470 server + one map; # it does NOT touch the existing stream :443 map, which is edited separately per stream-sni-additions.md). # # Data-path security gate: `ssl_verify_client on` against the DEVICE CA (with CRL) is the ONE gate for # the tunnelled base app. `on`, NEVER `optional` (PLAN P-D / R2). The public :8470 SERVER cert is the # LE wildcard (V3); the CLIENT trust anchor is the private device CA (V2) — two different chains. # # nginx 1.24: there is NO standalone `http2` directive here and NO `http2 off;` — HTTP/2 is off by # default on this listen and `http2 off;` is INVALID on 1.24 (would fail `nginx -t`, PLAN R7). # # A3 / FIX C-native-3 — cert→Host BINDING (the SINGLE load-bearing tenant-isolation control). On top # of `ssl_verify_client on` (which only proves the cert is device-CA-signed), njs parses the leaf's # dNSName SAN and a `map` requires its leftmost label == the leftmost label of the requested SNI, # `return 403` otherwise. A cert stamped `alice.terminal.yaojia.wang` may ONLY reach `alice.*`; a # tenant-A cert presented to tenant-B's host is denied. Rule lives in the `map` (never scattered # `if`s); exactly one `if` guards the single `return 403`. # # PREREQ (VPS main nginx.conf, MAIN context — NOT here): `load_module modules/ngx_http_js_module.so;` # (Debian nginx: `apt-get install nginx-module-njs`). Install the module file to /etc/nginx/njs/ # getCertSub.js so the relative `js_import` below resolves against the /etc/nginx prefix. js_import certsub from njs/getCertSub.js; js_set $cert_sub certsub.getCertSub; # leftmost dNSName SAN label of the verified client cert ('' on any parse failure) # Allow iff the requested SNI is EXACTLY `.terminal.yaojia.wang` — the cert's leftmost # dNSName label equals the requested subdomain, anchored to the FULL zone. Anchoring the zone here # (not just `