Deployment Guide
Advanced deployment topics for production environments.
Updating Mydia
Via Docker Compose
Via Docker CLI
docker stop mydia
docker rm mydia
docker pull ghcr.io/getmydia/mydia:latest
# Run your docker run command again
Migrations run automatically on startup. Your data in /config is preserved.
Reverse Proxy Configuration
Nginx
server {
listen 80;
server_name mydia.example.com;
location / {
proxy_pass http://localhost:4000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
Traefik
labels:
- "traefik.enable=true"
- "traefik.http.routers.mydia.rule=Host(`mydia.example.com`)"
- "traefik.http.routers.mydia.entrypoints=websecure"
- "traefik.http.routers.mydia.tls.certresolver=letsencrypt"
- "traefik.http.services.mydia.loadbalancer.server.port=4000"
Caddy
HTTPS Configuration
Configure Mydia for HTTPS access:
SSL termination should be handled by your reverse proxy.
WebSocket Configuration
For LiveView real-time features to work through a reverse proxy, ensure WebSocket connections are properly proxied:
- Nginx: Include
proxy_set_header UpgradeandConnection "upgrade" - Traefik: Automatic WebSocket support
- Caddy: Automatic WebSocket support
Origin Checking
By default, Mydia checks WebSocket origins for security. Configure as needed:
# Allow all origins (for IP-based access)
PHX_CHECK_ORIGIN=false
# Allow specific origins
PHX_CHECK_ORIGIN=https://mydia.example.com,http://192.168.1.100:4000
Backup Strategy
Automatic Backups
Mydia creates automatic database backups before migrations:
- Stored alongside the database
- 10 most recent backups retained
- Disable with
SKIP_BACKUPS=true(not recommended)
Manual Backup
For SQLite:
# Stop container
docker compose stop mydia
# Backup
cp /path/to/config/mydia.db /path/to/backup/mydia_$(date +%Y%m%d).db
# Start container
docker compose start mydia
Restore
# Stop container
docker compose stop mydia
# Restore
cp /path/to/backup/mydia_20240101.db /path/to/config/mydia.db
# Start container
docker compose start mydia
Monitoring
Health Checks
Mydia exposes a health endpoint:
Docker Health Check
services:
mydia:
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4000/health"]
interval: 30s
timeout: 10s
retries: 3
Logs
View container logs:
Configure log level:
High Availability
Note
High availability configurations are not officially supported but may work with PostgreSQL.
For HA deployments:
- Use PostgreSQL (external database)
- Deploy multiple Mydia instances behind a load balancer
- Ensure shared storage for
/config(excluding database) - Configure sticky sessions for LiveView
Beta Releases
Test new features before stable release:
Beta releases:
- May contain experimental features
- May have breaking changes
- Not recommended for production
Version Pinning
Pin to a specific version for stability:
Resource Requirements
Minimum
- 1 CPU core
- 512MB RAM
- 1GB disk (plus media storage)
Recommended
- 2+ CPU cores
- 1GB+ RAM
- SSD storage for database
NixOS Deployment
Mydia provides a NixOS module for declarative deployment:
Flake Configuration
# flake.nix
{
inputs.mydia.url = "github:getmydia/mydia";
outputs = { self, nixpkgs, mydia }: {
nixosConfigurations.myserver = nixpkgs.lib.nixosSystem {
modules = [ mydia.nixosModules.default ./configuration.nix ];
};
};
}
Module Configuration
# configuration.nix
{
services.mydia = {
enable = true;
host = "mydia.example.com";
secretKeyBaseFile = "/run/secrets/mydia/secret_key_base";
guardianSecretKeyFile = "/run/secrets/mydia/guardian_secret_key";
mediaLibraries = [ "/mnt/media/movies" "/mnt/media/tv" ];
};
}
Features
The NixOS module supports:
- OIDC authentication configuration
- Download client setup
- FlareSolverr integration
- Systemd security hardening
- Secrets management via files
See docs/nix.md in the repository for complete configuration options.
Troubleshooting
Container Won't Start
- Check logs:
docker compose logs mydia - Verify required environment variables are set
- Check volume permissions
Database Errors
- Check disk space
- Verify database file permissions
- Try restoring from backup
Connection Issues
- Verify port mapping
- Check firewall rules
- Test with
curl http://localhost:4000