Skip to content

Reverse proxy and HTTPS

For a domain name with HTTPS, put a reverse proxy in front of OwnTube. Send /media/* to the gateway and everything else to the web app.

Without a proxy the web app forwards /media/* to the gateway itself. That works, but every video byte then passes through Next.js. With a proxy the gateway serves media directly.

The default compose file only publishes the web app. If the proxy runs in Docker on the same network, use the service names (app:3000, gateway:8080). If it runs on the host, publish the gateway on localhost:

docker-compose.override.yml
services:
gateway:
ports:
- "127.0.0.1:8080:8080"

Add the public URL, so sign-in redirects and links in podcast feeds use it:

.env
AUTH_URL=https://tube.example.org
AUTH_TRUST_HOST=true

Add both to the environment: block of the app service as well, then run docker compose up -d.

Caddyfile
tube.example.org {
encode zstd gzip {
match {
not path /media/*
}
}
handle /media/* {
reverse_proxy 127.0.0.1:8080 {
flush_interval -1
}
}
handle {
reverse_proxy 127.0.0.1:3000
}
}

Caddy gets a certificate on its own and enables HTTP/3. Keep HTTP/3 on: Safari aborts a media request on every seek, and over HTTP/3 those aborts don’t disturb other requests on the same connection.

Terminal window
curl -I https://tube.example.org/

Play a video with the browser’s network panel open. Segment requests go to /media/… and return 200 or 206.