Serve fediverse paths on the UI's domain (phase 1, step 6)
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 12s
CI / test (push) Successful in 1m6s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
CI / validate-monitoring (push) Successful in 8s
CI / lint (push) Successful in 12s
CI / test (push) Successful in 1m6s
CI / images (push) Skipped
CI / assets (push) Skipped
CI / python-package (push) Skipped
CI / notify (push) Successful in 5s
- The UI container forwards /.well-known/{webfinger,nodeinfo,host-meta},
/nodeinfo/, /users/, /inbox and /actor to API_INTERNAL_URL (compose:
http://api:8000), passing Host and X-Forwarded-*; unset means no
forwarding
- The API's name is resolved per request via the container's resolver,
so the UI starts before the API and survives API restarts
- Compose passes the FEDERATION_* settings to api and worker;
.env.example documents them, including FEDERATION_KEY_SECRET
- gunicorn: disable the 26.x control socket (the container user has no
home directory)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MK52BGoJbPhZ1vSFuKcGUW
This commit is contained in:
1 parent
c0b9e85519
commit
8d12922f6a
5 files changed
+58
-1
No files matched your search
+34
-1
@@ -1,5 +1,6 @@
|
||||
#!/bin/sh
|
||||
# Point the UI at the API: rewrite config.js from $API_BASE_URL at container start.
|
||||
# Container start-up: point the UI at the API, and (when API_INTERNAL_URL is set)
|
||||
# forward the fediverse paths on this domain to the API.
|
||||
set -e
|
||||
case "$API_BASE_URL" in
|
||||
http://*|https://*) ;;
|
||||
@@ -11,3 +12,35 @@ window.SCROBBLER_CONFIG = {
|
||||
apiBaseUrl: "$url",
|
||||
};
|
||||
JS
|
||||
|
||||
mkdir -p /etc/nginx/scrobbler
|
||||
if [ -z "$API_INTERNAL_URL" ]; then
|
||||
: > /etc/nginx/scrobbler/federation.conf
|
||||
exit 0
|
||||
fi
|
||||
case "$API_INTERNAL_URL" in
|
||||
http://*|https://*) ;;
|
||||
*) echo "API_INTERNAL_URL must look like http://api:8000" >&2; exit 1 ;;
|
||||
esac
|
||||
upstream=$(printf '%s' "$API_INTERNAL_URL" | sed 's#/*$##')
|
||||
case "$upstream" in
|
||||
*://*/*) echo "API_INTERNAL_URL must not have a path" >&2; exit 1 ;;
|
||||
esac
|
||||
# Resolve the API's name per request (not once at start-up), so the UI starts even if
|
||||
# the API isn't up yet and keeps working when the API container is replaced.
|
||||
nameserver=$(awk '/^nameserver/ { print $2; exit }' /etc/resolv.conf)
|
||||
case "$nameserver" in *:*) nameserver="[$nameserver]" ;; esac
|
||||
cat > /etc/nginx/scrobbler/federation.conf <<NGINX
|
||||
# Fediverse (ActivityPub) paths live on the UI's domain; the API answers them.
|
||||
location ~ ^/(\.well-known/(webfinger|nodeinfo|host-meta)\$|nodeinfo/|users/|inbox\$|actor(/|\$)) {
|
||||
resolver ${nameserver:-127.0.0.11} valid=30s ipv6=off;
|
||||
set \$scrobbler_api $upstream;
|
||||
proxy_pass \$scrobbler_api;
|
||||
proxy_set_header Host \$host;
|
||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto \$scrobbler_forwarded_proto;
|
||||
proxy_set_header X-Forwarded-Host \$host;
|
||||
client_max_body_size 1m;
|
||||
}
|
||||
NGINX
|
||||
echo "forwarding fediverse paths to $upstream"
|
||||
Reference in new issue
Block a user