From 3e8b89ec7012ab1766b2458a38d5ac32cb748446 Mon Sep 17 00:00:00 2001 From: Christian Cleberg Date: Mon, 3 Aug 2026 15:47:25 -0500 Subject: nginx: make cleberg.net self-contained on the onion Serve images same-origin via a `location /img/ { alias /var/www/img/; }` block on cleberg.net, so the .onion no longer pulls subresources from the clearnet. Deliberately an nginx alias rather than a filesystem symlink. A symlink at /var/www/cleberg.net/img worked but was destroyed by the very next deploy -- the site deploys with `rsync --delete`, which removes anything in the destination that is not in the source tree, and that silently 404'd every image on the site. Config-level aliasing cannot be removed by a deploy. Tighten the cleberg.* CSP now that the site loads nothing cross-origin. The weblorg source was changed to emit root-relative stylesheet and image URLs, and the bubbles.town script was dropped, so parsing all deployed HTML returns zero absolute subresources. Dropped img-src https://img.cleberg.net, style-src and font-src https://cleberg.net, and script-src/connect-src https://bubbles.town; the policy is now default-src 'self' with no host allowances. upgrade-insecure-requests stays omitted: this vhost also serves the .onion over plain http, where it would upgrade same-origin subresource URLs to https and break them. Set Referrer-Policy to same-origin, restoring the value Cloudflare's security-headers toggle had been supplying. Removing that toggle silently regressed it to strict-origin-when-cross-origin, which still sends the origin to external sites; same-origin sends no referrer cross-origin at all. Verified over a real Tor circuit: article pages carry 4 relative subresources and 0 absolute, and images serve 200 from the onion. --- linux/nginx/etc/nginx/conf.d/cleberg.net.conf | 15 +++++++ .../etc/nginx/custom.d/http/content_type_maps.conf | 51 ++++++++++++++++------ 2 files changed, 52 insertions(+), 14 deletions(-) (limited to 'linux/nginx') diff --git a/linux/nginx/etc/nginx/conf.d/cleberg.net.conf b/linux/nginx/etc/nginx/conf.d/cleberg.net.conf index fb24a37..cc6aa19 100644 --- a/linux/nginx/etc/nginx/conf.d/cleberg.net.conf +++ b/linux/nginx/etc/nginx/conf.d/cleberg.net.conf @@ -20,6 +20,21 @@ server { add_header Onion-Location "http://paske4urhs6nttrtlkuwa5cowum3fjkc6yv6kl4ncx3mjxcd77764nqd.onion$request_uri" always; + # Images live in the img.cleberg.net docroot and are served same-origin here + # so the .onion is self-contained (see the onion-containment work, 2026-08-03). + # + # This is an nginx alias, NOT a filesystem symlink, on purpose. A symlink at + # /var/www/cleberg.net/img worked but was DESTROYED by the very next deploy: + # the site deploys with `rsync --delete`, which removes anything in the + # destination that is not in the source tree. That silently 404'd every image + # on the site. An alias lives in nginx config, so no deploy can remove it. + location /img/ { + alias /var/www/img/; + # This block sets no add_header of its own, so it inherits the + # server-level security headers. Do not add one without re-including + # custom.d/security/headers_in_location.conf -- nginx does not merge. + } + location /org/ { internal; alias /var/www/cleberg.net/org/; diff --git a/linux/nginx/etc/nginx/custom.d/http/content_type_maps.conf b/linux/nginx/etc/nginx/custom.d/http/content_type_maps.conf index f8a5e84..737eea3 100644 --- a/linux/nginx/etc/nginx/custom.d/http/content_type_maps.conf +++ b/linux/nginx/etc/nginx/custom.d/http/content_type_maps.conf @@ -53,20 +53,30 @@ map $sent_http_content_type $content_security_policy { ~*text/(html|javascript)|application/pdf|xml "default-src 'self'; img-src 'self' data:; base-uri 'none'; form-action 'self'; frame-ancestors 'none'; object-src 'none'"; } -# cleberg.* only. Mirrors what the site actually loads, verified by grepping -# the served HTML: -> img.cleberg.net (151),