Self-hosting
systemd, reverse proxy and tunnel in minimal form.
Production needs one directory, one systemd unit and one TLS entry point. All mutable state lives in JSON files in that directory, so backing up the directory is enough.
systemd unit
[Unit]
Description=media-web
After=network-online.target
[Service]
User=media
WorkingDirectory=/opt/media-web
Environment=MEDIA_WEB_PORT=8097
EnvironmentFile=/etc/media-web.env
ExecStart=/usr/bin/python3 /opt/media-web/app.py
Restart=on-failure
[Install]
WantedBy=multi-user.targetKeep the password in the EnvironmentFile with mode 600 — not in the unit or the command line.
Reverse proxy
nginx or Caddy handles TLS, forwarding and real-IP headers only. The app serves no static directory and you should not expose one.
location / {
proxy_pass http://127.0.0.1:8097;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}Public entry
- Cloudflare Tunnel: no inbound ports, works on home broadband
- Reverse proxy + port forward: you own certificates and exposure
- LAN only: just put the LAN address in the client
Backup and upgrade
Back up app.py and media-state.json. To upgrade: stop, replace files, start; the queue and position come back with the state file.
Known trade-off
The single file and zero dependencies are intentional. The cost is hand-assembled routes; if it grows further, split modules rather than switch frameworks.