Reverse proxy and HTTPS
Put Teldrive behind a TLS reverse proxy without breaking cookies, uploads, or SSE.
Keep Teldrive private and terminate TLS at the proxy:
browser ──HTTPS──► proxy ──HTTP/private network──► Teldrive :8080Trusted proxies
Trust only the address/CIDR of the proxy that connects directly to Teldrive:
http:
trusted-proxies:
- 127.0.0.1Teldrive accepts X-Forwarded-Proto: https only from trusted peers. Do not use 0.0.0.0/0 or ::/0.
Request logs report the client from X-Forwarded-For when the direct peer is trusted. Teldrive reads the header right-to-left, skipping trusted hops, so clients cannot spoof their address by prepending entries. Requests from untrusted peers log the peer address.
Caddy
Same host:
drive.example.com {
reverse_proxy 127.0.0.1:8080
}http:
address: 127.0.0.1:8080
trusted-proxies:
- 127.0.0.1For containerized Caddy, trust the actual container-network source CIDR instead.
Optional: built-in download cache
Teldrive embeds varc for sparse byte-range caching of downloads and media seeking. Enable it in Teldrive, not in Caddy; standard Caddy with the reverse_proxy configuration above is sufficient.
cache:
disk:
directory: /var/cache/teldrive
max-size: 10GB
min-free-space: 1GB
max-age: 168h
chunk-size: 64MiB
chunk-size-limit: 64MiB
chunk-streams: 4
read-ahead: 384MiBMount persistent storage at that path in the Teldrive container, writable by its user. Remove any old varc handler from Caddy to avoid maintaining two caches. See Download cache for container setup, tuning, and security considerations.
The built-in cache covers previews/streams and authorized public-share streams. Explicit attachment downloads (?download=1) bypass cache reads and writes. Authentication, ownership, share passwords, and download limits remain enforced before cached content is served. HEAD requests do not fetch file bytes.
For direct playback without credentials, security.public-file-content: true remains an explicit opt-in. Warning: anyone with a file ID can retrieve any active file on the instance; enabling a cache does not make this setting safer. Leave it disabled unless you intend to expose all active file content.
nginx
server {
listen 443 ssl;
server_name drive.example.com;
ssl_certificate /etc/letsencrypt/live/drive.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/drive.example.com/privkey.pem;
client_max_body_size 0;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_request_buffering off;
proxy_buffering off;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
}Adjust timeouts for your deployment; file transfers and SSE require long-lived requests.
Container binding
services:
teldrive:
ports:
- "127.0.0.1:8080:8080"
environment:
TELDRIVE_HTTP_ADDRESS: 0.0.0.0:8080
TELDRIVE_HTTP_TRUSTED_PROXIES: 172.18.0.0/16Replace the example CIDR with the network your proxy actually uses.
Verify
After enabling HTTPS, test:
- login and page refresh;
- upload/download;
- live task/progress updates;
- no repeated SSE reconnects or cookie errors.
If a CDN/load balancer sits in front of your proxy, Teldrive should still trust only its direct proxy peer; that proxy must sanitize forwarding headers.