Skip to content

Nginx Guide

arielaram edited this page Nov 16, 2026 · 1 revision

Nginx Guide

Nginx puts the admin panel on your own domain. Two setups are ready in the source repository under website/deploy/nginx/.

Which one

You have Use
A domain name pointing to this server nationdex-panel.conf (HTTPS, with Let's Encrypt)
A LAN address, a VPN, or TLS handled by something else nationdex-panel.http.conf (plain HTTP)

You do not need Nginx to use the panel. The bot serves it on port 3000 itself.

Before you start

  • Nginx installed (sudo apt install nginx on Debian or Ubuntu).
  • A domain, for example panel.yourdomain.com, with an A record pointing to the server's public IP.
  • Ports 80 and 443 open on your router or firewall.
  • The source file website/deploy/nginx/nationdex-panel.conf. Get it from the repository, or copy the file from GitHub.

HTTPS setup

  1. In .env set PANEL_HOST=127.0.0.1, so only Nginx reaches the panel. Restart the bot.

  2. Install certbot and get a certificate. Replace the domain:

    sudo apt install certbot
    sudo mkdir -p /var/www/certbot
    sudo certbot certonly --webroot -w /var/www/certbot -d panel.yourdomain.com

    The certificate ends up in /etc/letsencrypt/live/panel.yourdomain.com/.

  3. Copy the config and change the domain in three places (server_name twice, and the certificate paths):

    sudo cp website/deploy/nginx/nationdex-panel.conf /etc/nginx/conf.d/nationdex-panel.conf
    sudo nano /etc/nginx/conf.d/nationdex-panel.conf
  4. Test and reload:

    sudo nginx -t && sudo systemctl reload nginx
  5. Open https://panel.yourdomain.com.

The file also sets HSTS, rate-limits the sign-in form to 10 tries a minute per address, and allows 25 MB uploads (nation art and card backgrounds). The panel adds its own security headers, so Nginx does not repeat them.

Note: http2 on; needs Nginx 1.25.1 or newer. On older versions use listen 443 ssl http2; and delete that line.

Renewal is automatic with certbot's timer. Check with sudo certbot renew --dry-run.

HTTP only (LAN or VPN)

sudo cp website/deploy/nginx/nationdex-panel.http.conf /etc/nginx/conf.d/nationdex-panel.conf
sudo nginx -t && sudo systemctl reload nginx

Set PANEL_HOST=127.0.0.1 in .env and restart the bot. Use this only on a network you trust. Passwords travel unencrypted over plain HTTP.

Troubleshooting Nginx

Symptom Fix
502 Bad Gateway The bot is not running, or PANEL_PORT does not match 127.0.0.1:3000 in the upstream block
nginx: [emerg] ... bind() ... failed Another program uses port 80 or 443
Certificate errors in browser The certificate path in the config does not match the certbot domain
Sign-in keeps failing with 429 Rate limit reached: wait a minute
Panel says the cookie is not Secure Make sure proxy_set_header X-Forwarded-Proto $scheme; is present in the location block

For the bot itself (not the panel), do not publish port 2222 through Nginx. Keep it local.

Clone this wiki locally