Files
observer/asset/nginx/blackbeard.observer.conf
T
grenadeandClaude Opus 5 6d8c3fe3ea
deploy / build (push) Successful in 8m30s
deploy / deploy-web (push) Successful in 7s
deploy / deploy-api (push) Successful in 18s
infra: a dedicated access log for the public vhost, and deny hosting networks
The proxy's shared access.log mixes every site on oolon and records neither
Host nor Origin. Origin is the only field that separates our UI's WebSocket
from another site's, because browsers send no Referer on the upgrade. The
public vhost now writes its own JSON-lines log carrying both.

Ten days of the shared log showed no third-party site using the API, and two
headless pollers: an OVH host polling summary once a minute (88% of all
no-referer REST) and a Hetzner host identifying as `stardust-devops`. The
public vhost now refuses the hosting networks of both providers, from the
prefixes RIPEstat reports as announced by AS24940, AS213230, AS212317 and
AS16276, generated by script/deny-networks.py and committed so the list is
reviewed. AS35540 is OVH's residential broadband and is left out. Against the
same ten days, the list matches the two pollers and no visitor.

Refusals are a plain-text 403 and are still logged with "denied":1, so a VPN
user caught by it shows up rather than disappearing.

Closes #24

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E4Ldjix2ofMdQ7dzqgnYA8
2026-09-22 15:03:12 +03:00

126 lines
5.7 KiB
Plaintext

# Public vhost for blackbeard.observer, on the oolon edge proxy (kosherinata).
#
# Cert: Let's Encrypt via certbot + Cloudflare DNS-01 (architecture/external-tls.md).
# Installed by script/infra-setup.sh --edge, never by CI — the runner has no
# rights to read certificate keys or reload nginx on a shared edge proxy.
#
# ln -sf ../sites-available/blackbeard.observer.conf /etc/nginx/sites-enabled/
#
# listen 127.0.0.1:14443 + proxy_protocol, NOT 443: an nginx stream SNI router
# owns TCP 443 on this host and hands every non-passthrough name to the local
# https tier (architecture/reverse-proxies.md §5). Binding 443 here double-binds
# the port across http{} and stream{} — `nginx -t` cannot detect it, and the
# failure mode is nginx silently serving stale certificates. Copy this listen
# line from a currently ENABLED vhost; several files in sites-available have
# drifted from their enabled counterparts.
#
# NOTE: the upstream is CROSS-SITE. oolon is at kosherinata; the API runs on bob
# at hanzalova, because that is where the Planck node it reads lives. The hop
# traverses the WireGuard mesh, so the API's firewalld service must be open to
# the whole default zone rather than scoped to bob's own /16 — a rich rule
# scoped the way quantus-node's RPC is would reject oolon and the site would
# serve a static bundle with a dead /v1.
# The `blackbeard_api` upstream is declared once in
# conf.d/blackbeard-upstream.conf so both vhosts can use it independently, and
# `$connection_upgrade` comes from the proxy's existing conf.d map — the same
# one lair/quantus's vhost relies on. Both are installed by infra-setup.sh.
server {
listen 127.0.0.1:14443 ssl proxy_protocol;
http2 on;
server_name blackbeard.observer;
ssl_certificate /etc/letsencrypt/live/blackbeard.observer/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/blackbeard.observer/privkey.pem;
# TLS 1.2 stays enabled here, unlike the .internal vhost: this is a public
# site and its audience is not a controlled fleet.
ssl_protocols TLSv1.2 TLSv1.3;
# The vhost believes it is serving 127.0.0.1:14443, so any redirect it
# generates itself carries that port and is unreachable. Latent for a pure
# SPA, but one real directory under the webroot would break every URL
# without a trailing slash (reverse-proxies.md §4).
absolute_redirect off;
# Replaces the proxy's shared access.log for this name, rather than adding
# to it: the format is declared in conf.d/blackbeard-upstream.conf.
access_log /var/log/nginx/blackbeard.observer.access.log blackbeard_json;
# Hetzner and OVH hosting networks, from conf.d/blackbeard-deny.conf
# (script/deny-networks.py). Over 2026-09-12..22 this matched exactly two
# headless pollers and no visitor (blackbeard/observer#24). Whole vhost, not
# just /v1/: the page is useless without the API, and a plain 403 says why
# where a half-loaded site would not. Denials still reach the log above with
# "denied":1, so a VPN user caught by it is visible rather than silent.
#
# A speed bump rather than a gate: anything refused here can move to
# another provider. It does not replace an Origin check or credentials.
#
# Rewritten into a location rather than `return 403 "..."` here, because
# default_type cannot be set inside a server-level `if`, and the proxy's
# default of application/octet-stream makes a browser download the refusal
# instead of showing it. Not `error_page 403`, which would also answer a
# mislabelled webroot with this message and send the diagnosis elsewhere.
if ($blackbeard_denied) {
rewrite ^ /.denied last;
}
location = /.denied {
internal;
default_type text/plain;
return 403 "blackbeard.observer does not serve requests from hosting-provider networks.\n";
}
root /var/www/blackbeard.observer;
index index.html;
# The built SPA. Hashed asset filenames are immutable; index.html must not
# be cached or a deploy would leave browsers loading a bundle that no longer
# exists.
location / {
try_files $uri $uri/ /index.html;
}
location /assets/ {
expires 1y;
add_header Cache-Control "public, immutable";
}
location = /index.html {
add_header Cache-Control "no-cache";
}
location /v1/ {
proxy_pass http://blackbeard_api;
proxy_http_version 1.1;
# The WebSocket upgrade. Without these three lines the socket silently
# falls back to a plain request that hangs, and the page shows
# "reconnecting" forever with nothing in any log.
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# A chain can be quiet for a minute at a time and a browser tab can sit
# open all day. The 60s default would cut every socket mid-session and
# surface as an unexplained disconnect.
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
# Buffering an endless stream is exactly wrong: it would hold each
# message until a buffer filled, which on a quiet chain is minutes.
proxy_buffering off;
}
# Public, read-only, entirely derived from public block headers. No auth,
# nothing to leak; documented here so the absence is deliberate rather than
# an oversight. The network deny list above is about load, not secrecy.
add_header X-Content-Type-Options nosniff always;
add_header Referrer-Policy same-origin always;
}