🔥 Sale — −10% off everything

Server Configuration & Optimization

This guide covers tuning, security and troubleshooting for a production StreamVaultX server. For first-time setup see Installation & Server Requirements.

1. Optimized nginx config

A high-traffic tube site serves many small requests plus large media files. Use this as a base for your site block.

# /etc/nginx/nginx.conf  (inside http { })
sendfile        on;
tcp_nopush      on;
tcp_nodelay     on;
keepalive_timeout 65;
gzip on;
gzip_types text/css application/javascript application/json image/svg+xml;
# raise limits for many concurrent viewers
# (also set LimitNOFILE in the systemd unit, see section 4)
# your site block
server {
    listen 443 ssl http2;
    server_name yourtube.com;
    client_max_body_size 4096m;          # large uploads

    # static assets — served straight from disk, cached hard
    location /uploads/ {
        alias /opt/streamvault/public/uploads/;
        expires 30d; add_header Cache-Control "public, immutable";
        access_log off;
    }
    # self-hosted HLS / media — streaming friendly
    location /media/ {
        alias /opt/streamvault/data/media/;
        expires 7d;
        add_header Cache-Control "public";
        sendfile on; tcp_nopush on;
        access_log off;
    }

    location / {
        proxy_pass http://127.0.0.1:8097;
        proxy_http_version 1.1;
        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;
        proxy_buffering off;             # stream responses without buffering
        proxy_read_timeout 300s;
    }
}

Reload after changes: nginx -t && systemctl reload nginx.

2. Cloudflare (recommended)

  • Set SSL/TLS mode to Full (strict) and keep the orange cloud (proxied) on.
  • StreamVaultX already reads the real visitor IP and country from Cloudflare headers (CF-Connecting-IP, CF-IPCountry) — important for anti-bot and per-country ad routing (TDS).
  • Cache static files: a rule like yourtube.com/uploads/* and /media/* → Cache Everything, Edge TTL a few days. Do not cache /admin or HTML pages.
  • To log the real IP in nginx too, install the RealIP module config with Cloudflare's IP ranges (set_real_ip_from + real_ip_header CF-Connecting-IP).

3. Firewall & SSH security

ufw allow OpenSSH
ufw allow 80,443/tcp
ufw enable

# ban brute-force SSH attempts
apt install -y fail2ban
systemctl enable --now fail2ban

Only ports 22, 80 and 443 need to be open. StreamVaultX listens on 127.0.0.1 only, so it is never exposed directly.

4. systemd hardening & limits

Add resource limits to the service so it survives traffic spikes:

# /etc/systemd/system/streamvault.service  (in [Service])
LimitNOFILE=65535
NoNewPrivileges=true
Restart=always
RestartSec=2
# optional memory ceiling
# MemoryMax=1500M
systemctl daemon-reload && systemctl restart streamvault

5. Swap (for small-RAM VPS)

On a 1 GB VPS add swap so imports/transcoding never OOM:

fallocate -l 2G /swapfile
chmod 600 /swapfile
mkswap /swapfile && swapon /swapfile
echo '/swapfile none swap sw 0 0' >> /etc/fstab

6. Transcoding (ffmpeg) load

"Save to server" (HLS) and thumbnail generation use ffmpeg, which is CPU-heavy. On a small VPS, run bulk imports during off-peak hours and import in smaller batches. More vCPU = faster transcoding; it does not affect page-serving speed (pages are served from RAM).

7. SSL auto-renewal

certbot installs a renewal timer automatically. Verify it:

systemctl status certbot.timer
certbot renew --dry-run

8. Automatic backups (cron)

Back up the config and data daily and keep the last 7:

mkdir -p /root/backup
cat >/etc/cron.daily/streamvault-backup <<'SH'
#!/bin/sh
cd /opt/streamvault
tar czf /root/backup/streamvault-$(date +%F).tgz config.json data
ls -1t /root/backup/streamvault-*.tgz | tail -n +8 | xargs -r rm -f
SH
chmod +x /etc/cron.daily/streamvault-backup

Store a copy off-server too (object storage, another box). The data/ folder holds your database and media.

9. Troubleshooting

SymptomCause & fix
Service won't start / "address already in use"Another process uses the listen port. Change it in config.json or free the port: fuser -k 8097/tcp.
502 Bad GatewayApp is down or on a different port than nginx's proxy_pass. Check journalctl -u streamvault -n 50 and match the port.
"License activation failed"Wrong/empty license_key, the domain is already bound to another server, or outbound HTTPS is blocked. Release the old domain in your store account, verify the key, and allow outbound 443.
Uploads/transcoding failffmpeg missing or no disk space. apt install ffmpeg; check df -h.
Thumbnails not generatingffmpeg missing, or the public/uploads folder is not writable by the service user. chown -R www-data:www-data /opt/streamvault.
Wrong visitor country / all traffic looks like one IPBehind a proxy without real-IP headers. Put the site behind Cloudflare (sends CF-Connecting-IP) or forward X-Forwarded-For in nginx.
Site slow after many videosAdd RAM (catalog is held in memory) and make sure static files are cached by nginx/Cloudflare, not proxied through the app.
HTTPS not workingRe-run certbot --nginx -d yourtube.com and confirm DNS points to this server.

Need help?

Contact support from the store footer with your license key and the output of journalctl -u streamvault -n 100.

We use cookies to improve your experience and measure traffic. Learn more