~ knotless Search/
↑↓ move↵ open⇧↵ all results

socialweb.computer/socialweb-computer-kcp

socialweb.computer: a compute market on atproto (kcp)

1 collaborator
0
0
134 lines · 4.8 KB Raw History
# ssh -NnT  -R 0.0.0.0:80:127.0.0.1:80 -R 0.0.0.0:443:127.0.0.1:443 root@fedproxy.com
# sudo -E caddy run --config Caddyfile
#
# ssh -NnT -p 2222 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PasswordAuthentication=no -R spindle-0001:80:127.0.0.1:8080 johnandersen777.bsky.social@localhost
# clear; rm -rf /tmp/ssh-fwd-*; THIS_ENDPOINT=fedproxy.com CADDY_SOCK=${PWD}/caddy-admin.sock CF_API_TOKEN=... go run cmd/atprp-ssh-relay/main.go
# CADDY_SOCK=${PWD}/caddy-admin.sock LISTEN_ADDR=127.0.0.1:5555 go run cmd/caddy-check-dns-from-config/main.go
# curl -v --unix-socket caddy-admin.sock http://127.0.0.1/config/ | jq
{
	# Expose Caddy's admin API on a Unix socket

	# For local dev:
	# admin unix/{env.PWD}/caddy-admin.sock
	admin unix//opt/caddy/caddy-admin.sock
	log default {
		level info
	}

	# On-demand TLS gating: the ingress relay's ask listener approves a name
	# Caddy already routes (exact host matchers and single-label *.suffix, as
	# caddy-check-dns-from-config on 5555 did) or a custom hostname whose _xrpc
	# TXT record names a live subscriber. Caddy's `ask` HTTP client cannot dial
	# Unix sockets, so this is loopback TCP.
	on_demand_tls {
		ask http://127.0.0.1:5556/check
	}

	# Never idle-close connections at the server level. Caddy does not count
	# WebSocket ping/pong frames as activity, so any non-zero idle timeout
	# silently kills long-lived-but-quiet WS sessions (xrpc subscriptions).
	# Dead peers are caught at the TCP level via keepalive probes. This mirrors
	# the idle_timeout "0" atprp-ssh-relay PATCHes onto srv0 at runtime.
	servers {
		timeouts {
			idle 0
		}
	}
}

# Web UI. Wildcard catch-all + DNS-01 issuance is configured dynamically
# by atprp-ssh-relay's ensureSrv0Exists when CF_API_TOKEN is set.
https://fedproxy.com {
	file_server {
		root /var/www/html
		index index.html
	}
}

# Serve the shared "*.fedproxy.com" wildcard cert (managed by atprp-ssh-relay's
# Cloudflare DNS-01 policy) for the static single-label hosts below, instead of
# letting each site block trigger its OWN per-name ACME issuance. Per-name
# issuance is fatal here: the relay's reconcile loop and SSH clients push Caddy
# config updates, and every config reload cancels any in-flight ACME order, so a
# dedicated xrpc/rp cert never survives long enough to finalize (the wildcard
# does, because it's obtained once and then just served). xrpc and rp are single
# labels under fedproxy.com, so the "*.fedproxy.com" cert already covers them.
# Caddy re-reads file certs on each config load, and reloads are frequent here,
# so wildcard renewals propagate well within the renewal window.
(wildcard_cert) {
	tls /root/.local/share/caddy/certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.fedproxy.com/wildcard_.fedproxy.com.crt /root/.local/share/caddy/certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.fedproxy.com/wildcard_.fedproxy.com.key
}

# OAuth Workload Identity Reverse Proxy
https://rp.fedproxy.com {
	import wildcard_cert
	reverse_proxy unix//opt/caddy/web-ui.sock
}

# WebSocket-friendly reverse_proxy options for the xrpc upstream:
#   flush_interval -1   stream responses byte-for-byte, no buffering (required
#                       so server->client WS/SSE frames are not held back).
#   stream_close_delay  on config reload, let in-flight streams drain up to 5m
#                       instead of being cut instantly (reloads are frequent).
#   keepalive_interval  probe the upstream over the unix socket every 30s so
#                       half-open connections are detected and reaped.
(xrpc_proxy) {
	reverse_proxy unix//opt/caddy/xrpc-relay-server.sock {
		flush_interval -1
		stream_close_delay 5m
		transport http {
			keepalive_interval 30s
		}
	}
}

https://xrpc.fedproxy.com {
	import wildcard_cert
	import xrpc_proxy
}

https://*.xrpc.fedproxy.com {
	tls {
		dns cloudflare {
			api_token {env.CF_API_TOKEN}
		}
	}
	import xrpc_proxy
}

# Test env
(test_xrpc_proxy) {
	reverse_proxy unix//opt/caddy/xrpc-relay-server-test.sock {
		flush_interval -1
		stream_close_delay 5m
		transport http {
			keepalive_interval 30s
		}
	}
}

https://xrpc-test.fedproxy.com {
	import wildcard_cert
	import test_xrpc_proxy
}

https://*.xrpc-test.fedproxy.com {
	tls {
		dns cloudflare {
			api_token {env.CF_API_TOKEN}
		}
	}
	import test_xrpc_proxy
}

https://irc.fedfork.com {
	reverse_proxy http://127.0.0.1:8080
}

# Custom domains (the relay's _xrpc TXT aliases) are NOT a site block here: a
# hostless `https://` block is a terminal catch-all route, and atprp-ssh-relay
# appends every tunnel route after the Caddyfile's, so it would shadow them; its
# subject-less on_demand policy would also take the *.fedproxy.com wildcard's
# issuance from atprp's DNS-01 policy. infra/fedproxy-legacy/xrpc-custom-domains.sh
# adds the route (every host not under fedproxy.com) and an HTTP-01 fallback
# issuer through the admin API; run it again after a Caddy restart.