Reverse proxy and HTTPS
For access over HTTPS on your own domain, put a reverse proxy in front of OwnTube. Route /media/* straight to the gateway and everything else to the web app.
Without a proxy, the web app forwards /media/* to the gateway itself, which works but sends every video byte through Next.js. With a proxy, the gateway serves media directly. HTTPS is also needed for the iPhone app, the PWA install prompt and casting from most browsers.
Expose the gateway port
The default compose file publishes only the web app. If the proxy runs on the same Docker network, refer to the services by name (app:3000, gateway:8080). If it runs on the host, publish the gateway on localhost:
services:
gateway:
ports:
- "127.0.0.1:8080:8080"
Tell the web app its address
Add the public URL to .env and to the app's environment: block, so sign-in redirects and links in podcast feeds use it:
AUTH_URL=https://tube.example.org
AUTH_TRUST_HOST=true
Caddy
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 enables HTTP/3 by default. Keep it on: Safari aborts media requests on every seek, and over HTTP/3 those aborts cannot disturb other requests on the same connection.
nginx
server {
listen 443 ssl;
http2 on;
server_name tube.example.org;
# ssl_certificate …; ssl_certificate_key …;
location /media/ {
proxy_pass http://127.0.0.1:8080;
proxy_buffering off;
proxy_request_buffering off;
proxy_read_timeout 1h;
proxy_set_header Host $host;
}
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Check it
curl -I https://tube.example.org/
docker compose logs --tail 50 gateway
Play a video and open the browser's network panel: segment requests go to /media/… and return 200 or 206.