From 4049d663a71d5015c69f05e00002e04a2f0eaf8b Mon Sep 17 00:00:00 2001 From: Hoelee Date: Tue, 10 Nov 2026 14:35:56 +0800 Subject: [PATCH] deploy: how the /check/ location is actually served, and the three properties that matter Records the live shape after the 2026-11-10 production cut-over: the location lives inside the www nginx conf, access_log off is a privacy requirement rather than tuning, and X-Robots-Tag has exactly one source. The X-Robots-Tag note is a defect that was measured, not theorised: with both the app and nginx setting the header, a report answered with 'noindex, nofollow' AND 'index, follow' on the same response. --- .gitignore | 1 + deploy/check.nginx.conf | 64 +++++++++++++++++++++++++++-------------- 2 files changed, 44 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index e373e7c..f30ea9d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ npm-debug.log* .DS_Store *.log tmp/ +.codegraph/ diff --git a/deploy/check.nginx.conf b/deploy/check.nginx.conf index 2bebbe7..d4497ab 100644 --- a/deploy/check.nginx.conf +++ b/deploy/check.nginx.conf @@ -1,39 +1,61 @@ -# nginx location for hoelee-check — to be added to the www.hoelee.com server block on unRaid -# (container nginx-www-hoelee). Not applied yet. +# Where the /check/ location actually lives # -# Two properties matter more than anything else here: -# 1. `^~ /check/` wins over the static-extension regex, so /check/report/hoelee.com is proxied -# instead of being treated as a file named "hoelee.com". +# The production location is NOT a separate file — it is part of +# www-hoelee-com/deploy/nginx/default.conf (the `location ^~ /check/` block plus the +# `$check_robots` map), because the www reverse proxy is the only thing that sees the public +# hostname. This file is the record of what that block must contain; it is not deployed as an +# include. Live file on the unRaid host: +# `/mnt/user/docker/www-hoelee-com/conf.d/default.conf`, bind-mounted read-only into +# `nginx-www-hoelee`. A change there needs a container RESTART (single-file bind mount = new +# inode), not `nginx -s reload`. +# +# Three properties are load-bearing, not stylistic: +# 1. `^~ /check/` — without it the `^/[a-z0-9][a-z0-9_-]{0,80}/?$` slug regex swallows /check +# and linkd answers 404. # 2. `access_log off;` — an access log of /check/report/ IS the query log the site -# promises not to keep. Without this line the promise is false. +# promises not to keep. Verified 2026-11-10: a report request leaves no line in the +# container log, while ordinary page views still do. +# 3. Exactly one X-Robots-Tag, decided by the `$check_robots` map + `proxy_hide_header`. The +# service sets `noindex, nofollow` on report pages itself, so hiding it and letting nginx +# decide is the only way to avoid shipping `noindex` and `index, follow` together (measured). # -# proxy_pass has no URI part, so the service receives the full /check/... path it expects. +# `proxy_pass $check` uses a variable for the same reason linkd does: a literal upstream name +# makes this container refuse to boot while the checker is being redeployed. location ^~ /check/ { access_log off; - proxy_pass http://hoelee-check:3000; + proxy_pass $check; proxy_http_version 1.1; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; + # $http_host, not $host: $host drops the port, so the LAN preview at :8082 would claim the + # wrong origin. X-Forwarded-For is overwritten, never appended — a client-settable first hop + # would let anyone mint a fresh rate-limit bucket per request. + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Proto $hoelee_proto; + proxy_set_header X-Forwarded-Host $http_host; proxy_connect_timeout 5s; - proxy_send_timeout 25s; - proxy_read_timeout 25s; + proxy_send_timeout 20s; + proxy_read_timeout 20s; - # Report pages set X-Robots-Tag themselves; keep nginx from buffering a slow report behind - # a full response. - proxy_buffering on; - proxy_buffers 8 16k; + proxy_hide_header X-Robots-Tag; + add_header X-Robots-Tag $check_robots always; } # Smoke tests after adding this (from any machine): # curl -sS -o /dev/null -w '%{http_code}\n' https://www.hoelee.com/check/ # curl -sS https://www.hoelee.com/check/api/health -# curl -sS -o /dev/null -w '%{http_code}\n' https://www.hoelee.com/check/report/hoelee.com -# curl -sSI https://www.hoelee.com/check/report/hoelee.com | grep -i x-robots-tag # noindex +# curl -sS -o /dev/null -w '%{http_code} %{time_total}s\n' https://www.hoelee.com/check/report/hoelee.com +# curl -sSI https://www.hoelee.com/check/report/hoelee.com | grep -ci x-robots-tag # exactly 1, noindex +# curl -sSI https://www.hoelee.com/check/ | grep -i x-robots-tag # index, follow # curl -sS -o /dev/null -w '%{http_code}\n' 'https://www.hoelee.com/check/?d=127.0.0.1' # 400 # for i in $(seq 1 12); do curl -s -o /dev/null -w '%{http_code} ' \ -# 'https://www.hoelee.com/check/report/example.com?fresh=1'; done # ends in 429 -# # and afterwards: confirm nothing appeared in the nginx access log for /check/ +# 'https://www.hoelee.com/check/report/example.com?fresh=1'; done # 10x200 then 429 +# curl -sSI https://www.hoelee.com/check | head -1 # 301 -> /check/ +# # afterwards: confirm the container log holds no /check/report line +# +# `?fresh=1` is required for the rate-limit test: a cached report is served without spending a +# token (by design, so a WhatsApp or Telegram prefetch never becomes a fresh scan), so repeating +# a plain cached URL ten times proves nothing and looks like the limiter is broken.