From bffe4ee04c8a794d4927a0e5320c36d9cd4b26ea Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 13 Aug 2026 14:38:20 +0200 Subject: [PATCH] fix(peertube): derive the webserver authority from the TLS lookup The role set no webserver scheme or port, so PeerTube kept its upstream default of https on 443 even on an onion node, where the vhost is plaintext and Tor publishes port 80. redirect_uris.py meanwhile resolves the same deployment through resolve_enabled and registers http://video./* with Keycloak, so the plugin asked for an https callback against an http registration and Keycloak answered invalid_redirect_uri four times in its event log. Both values now come from the tls lookup, which decides scheme and port together from one resolve_enabled call -- the same predicate redirect_uris.py uses for the registration and nginx_ssl_header.j2 uses for its listen directive. There is no second expression left that could drift. The port is not cosmetic. WEBSERVER.URL is built as scheme://hostname:port and sanitizeUrl drops the port only for (https,443) and (http,80), so flipping the scheme alone would have produced http://video.:443 -- still unmatched against the portless registration, and against a port Tor never publishes. 095197a65 removed these two variables in 2022 because they were hardcoded to https=false and port=9000, which is the internal listener and was wrong for every proxied deployment. That fix stands: the upstream default is correct for clearnet behind the proxy. It is only wrong where TLS is off, which is what this restores, conditionally. Evidence: run 31658270172 job 94319317216, artifact 9171666491 keycloak event log (error="invalid_redirect_uri", redirect_uri="https://video./plugins/ auth-openid-connect/router/code-cb"), and the peertube service log label [video.:443] proving PORT was 443 at runtime. Co-Authored-By: Claude Opus 5 (1M context) --- roles/web-app-peertube/templates/env.j2 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/roles/web-app-peertube/templates/env.j2 b/roles/web-app-peertube/templates/env.j2 index 5d927e722a..4683468b6a 100644 --- a/roles/web-app-peertube/templates/env.j2 +++ b/roles/web-app-peertube/templates/env.j2 @@ -13,6 +13,8 @@ PEERTUBE_REDIS_PORT={{ lookup('engine', 'redis', application_id, 'port') }} PEERTUBE_REDIS_AUTH={{ lookup('engine', 'redis', application_id, 'password') | dotenv_quote }} PEERTUBE_WEBSERVER_HOSTNAME={{ lookup('domain',application_id) }} +PEERTUBE_WEBSERVER_HTTPS={{ lookup('tls', application_id, 'enabled') | string | lower }} +PEERTUBE_WEBSERVER_PORT={{ lookup('tls', application_id, 'ports.web') }} PEERTUBE_TRUST_PROXY=["127.0.0.1", "loopback"] {% if PEERTUBE_LIVE_ENABLED | bool %}