Reverse Proxy
Configure Nginx, Caddy, or Traefik as a reverse proxy for milmil.
A reverse proxy is required for HTTPS and recommended for production deployments. milmil uses WebSocket connections for real-time features (danmaku, notifications), so your proxy must support WebSocket upgrades.
Nginx
server {
listen 443 ssl http2;
server_name milmil.example.com;
ssl_certificate /etc/letsencrypt/live/milmil.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/milmil.example.com/privkey.pem;
# Frontend
location / {
proxy_pass http://127.0.0.1:3000;
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;
}
# API + WebSocket
location /api/ {
proxy_pass http://127.0.0.1:8080;
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;
}
# WebSocket endpoint
location /ws {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
# Streaming — increase timeouts and disable buffering
location /api/v1/stream/ {
proxy_pass http://127.0.0.1:8080;
proxy_http_version 1.1;
proxy_buffering off;
proxy_request_buffering off;
client_max_body_size 0;
proxy_read_timeout 3600s;
proxy_send_timeout 3600s;
}
}
# HTTP to HTTPS redirect
server {
listen 80;
server_name milmil.example.com;
return 301 https://$host$request_uri;
}The streaming location block disables buffering and increases timeouts. Without this, large video files may fail to stream.
Let's Encrypt with Certbot
sudo apt install certbot python3-certbot-nginx
sudo certbot --nginx -d milmil.example.comTroubleshooting
Ensure your proxy passes the Upgrade and Connection headers for the /ws and /api/ paths. Check that proxy_http_version 1.1 is set in Nginx.
Disable proxy buffering for the streaming endpoint. In Nginx, set proxy_buffering off and increase proxy_read_timeout.
Check that both milmil-api (port 8080) and milmil-web (port 3000) are running. Verify with docker ps.