> For the complete documentation index, see [llms.txt](https://docs.drakodevelopment.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.drakodevelopment.net/getting-started/dashboard-setup/nginx-step-by-step.md).

# Nginx Step By Step

This guide gives your Drako Bot v2 dashboard a secure website address, such as https\://dashboard.example.com.

Follow each step in order. Check the result before moving to the next step.

## Before you start

This guide is for a bot running **directly on an Ubuntu or Debian server**, with Nginx installed on that same server. You need administrator access through SSH, a domain you control, and the dashboard addon already installed and configured.

If you connect from Windows, run the Linux commands **in your server's SSH terminal**, not in your computer's normal PowerShell window.

* Bot inside Pelican or Docker? Start with the [Pelican and Docker guide](broken://pages/e7af9fb80e6f3d1541b4a5dc2c2b1f1fb22977eb).
* Want Cloudflare Tunnel instead? Use the [Cloudflare Tunnel guide](broken://pages/e48b54f71a9aa6e1e2df4faf660a36fd579e7308).
* Addon not configured yet? Complete [Dashboard Setup](https://docs.drakodevelopment.net/getting-started/dashboard-setup) first.

{% hint style="info" %}
This setup uses Nginx to provide HTTPS. The connection between Nginx and Drako stays local and uses HTTP.
{% endhint %}

{% stepper %}
{% step %}

## Write down your addresses

Replace `dashboard.example.com` throughout this guide with your chosen dashboard name.

| Detail                       | Example                             | What it is for                     |
| ---------------------------- | ----------------------------------- | ---------------------------------- |
| Dashboard name               | `dashboard.example.com`             | DNS and Nginx                      |
| Public website address       | `https://dashboard.example.com`     | Drako's URL and your browser       |
| Server's public IPv4 address | Get this from your hosting provider | Your DNS record                    |
| Drako dashboard port         | `3000`                              | Drako and Nginx's local connection |
| Local dashboard address      | `http://127.0.0.1:3000`             | Nginx connects here                |

Find the port in the existing `Dashboard` section of `config/core.yml`, or in `DASHBOARD_PORT` if you use `.env`.

If your dashboard port is `3016`, replace `3000` with `3016` in the Drako settings, local checks, and Nginx configuration below. Keep the website address without a port number.

`127.0.0.1` means “this server.” Keep it as shown when Nginx and Drako both run directly on this server.
{% endstep %}

{% step %}

## Point your domain to the server

Open the DNS settings at the company that manages your domain.

Create this record:

| Field           | Value                             |
| --------------- | --------------------------------- |
| Type            | `A`                               |
| Name or Host    | `dashboard`                       |
| Value or Target | Your server's public IPv4 address |
| TTL             | Automatic or the default          |

Some providers expect the full name, `dashboard.example.com`, in the Name field. Follow the example shown in their interface.

{% hint style="warning" %}
If you use Cloudflare for DNS, set this record to **DNS only** with the grey cloud for this guide. Do not create a tunnel route for the same hostname.
{% endhint %}

If a record for this exact name already exists, check what it serves before changing it. This guide uses IPv4. If the hostname also has an `AAAA` record, ask the administrator to configure Nginx for IPv6 too or remove that hostname's unused IPv6 record. An old IPv6 record can send visitors to the wrong server.

In the server's SSH terminal, check the address:

```bash
getent ahostsv4 dashboard.example.com
```

{% hint style="success" %}
**Ready to continue:** the returned IPv4 address matches your server. DNS changes may take time to appear.
{% endhint %}
{% endstep %}

{% step %}

## Set up Drako's public address

Back up the bot's settings file. Edit the settings source your bot actually uses.

### If you use `config/core.yml`

Find the existing `Dashboard:` section and update these fields. Keep your existing license and credentials in that section.

```yaml
Dashboard:
  Enabled: true
  URL: "https://dashboard.example.com"
  Port: 3000
  Hosting: "direct"
  # Keep your existing license and Discord credentials.
```

{% hint style="warning" %}
Ensure that you don't include trailing slashes in the URL. It should match your exact domain, such as dashboard.example.com
{% endhint %}

### If you use `.env` or hosting environment variables

Update these values in your active `.env` file or hosting startup settings:

```dotenv
DASHBOARD_ENABLED=true
DASHBOARD_URL=https://dashboard.example.com
DASHBOARD_PORT=3000
DASHBOARD_HOSTING=direct
```

When Drako loads a `.env` file, these startup settings come from that file instead of the YAML section. Hosting environment variables can override the file. Keep existing credentials.

`Hosting: "direct"` means Drako is installed directly on this Windows/Linux machine. With an HTTPS URL, it chooses the local listening and proxy defaults for this guide. The bot generates and saves its session secret automatically; keep any secret it has already saved.

If you previously added advanced listening or proxy settings, they still override these defaults. See [Existing advanced settings](#existing-advanced-settings) below if you are changing your hosting setup.

### Update the Discord return address

1. Open the [Discord Developer Portal](https://discord.com/developers/applications).
2. Select the application used by your bot.
3. Open **OAuth2** and find **Redirects**.
4. Add `https://dashboard.example.com/api/auth/callback`, using your own dashboard name.
5. Save the changes.

If your bot already has `RedirectURI` or `DASHBOARD_REDIRECTURI` set, update that setting to the same address.

Save your settings and restart Drako using your usual bot manager. Do not start a second copy of the bot.

In the server's SSH terminal, run the following check. If `curl` is missing, install it first with `sudo apt update` followed by `sudo apt install curl`.

```bash
curl -I http://127.0.0.1:3000/
```

{% hint style="success" %}
**Ready to continue:** the response includes `200` and a `Content-Type` containing `text/html`.
{% endhint %}

If it says `Connection refused`, check the bot's startup log, enabled setting, and port. If it says `426 Upgrade Required`, investigate the service listening on that port before continuing. A public HTTPS URL does not make Drako's local listener use HTTPS.
{% endstep %}

{% step %}

## Install Nginx and allow website traffic

{% hint style="warning" %}
**Run on the server through SSH.** Enter one command at a time:
{% endhint %}

```bash
sudo apt update
sudo apt install nginx curl nano
sudo systemctl enable --now nginx
```

If another web server already uses ports `80` or `443`, have the server administrator add this dashboard to the existing setup. Do not stop unrelated websites to free the ports.

In your hosting provider's firewall, allow incoming **TCP 80** and **TCP 443**. Keep existing SSH access allowed.

Check whether Ubuntu's UFW firewall is active:

```bash
sudo ufw status
```

If it says **Status: active**, add these rules:

```bash
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
```

If UFW is inactive or not installed, do not enable it as part of this guide. Check any other firewall your server uses with your hosting provider.

The local Drako port, such as `3000`, does not need a public inbound rule for this setup.
{% endstep %}

{% step %}

## Add the dashboard to Nginx

Create a separate file for this website. Replace the example domain in the filename too:

```bash
sudo nano /etc/nginx/sites-available/dashboard.example.com
```

If the file already contains a website configuration, back it up and review it before editing.

Paste this configuration. Change `dashboard.example.com` and, if needed, port `3000`:

```nginx
server {
    listen 80;
    server_name dashboard.example.com;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_http_version 1.1;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Connection "";
        proxy_buffering off;
        proxy_cache off;
        proxy_read_timeout 300s;
    }
}
```

{% hint style="info" %}
Keep the `$host`, `$scheme`, and `$remote_addr` text exactly as shown. These are Nginx variables, not placeholders for you to fill in.

The headers let Drako recognize the public request correctly. Buffering is disabled so dashboard updates can arrive promptly. These directives are documented in the [Nginx proxy reference](https://nginx.org/en/docs/http/ngx_http_proxy_module.html).
{% endhint %}

Save in Nano: press **Ctrl + O**, press **Enter**, then press **Ctrl + X**.

Enable this website:

```bash
sudo ln -s /etc/nginx/sites-available/dashboard.example.com /etc/nginx/sites-enabled/dashboard.example.com
```

If it says `File exists`, check that the existing link points to the intended file; do not delete it blindly.

Check the configuration:

```bash
sudo nginx -t
```

Only if the check succeeds, apply it:

```bash
sudo systemctl reload nginx
```

Open `http://dashboard.example.com` in your browser. At this stage it should show the Drako dashboard.

{% hint style="warning" %}
**Wait until HTTPS is working before signing in.**
{% endhint %}

If you see the Nginx welcome page, check `server_name`, DNS, and whether you enabled and reloaded the correct file. For `502 Bad Gateway`, repeat the local test in Step 3.
{% endstep %}

{% step %}

## Turn on HTTPS

The following uses Certbot's snap installation. If Certbot already manages certificates on this server, use that existing installation and skip installing another copy. For a different installation method or a server without snap support, follow the [official Certbot instructions](https://certbot.eff.org/instructions?ws=nginx\&os=snap).

For a fresh installation:

```bash
sudo apt install snapd
```

If you just installed snapd, reconnect your SSH session, then run:

```bash
sudo snap install snapd
sudo snap install --classic certbot
```

If snap reports an installation or system-support error, complete the [snap setup instructions](https://snapcraft.io/docs/tutorials/install-the-daemon/debian/) before continuing.

Request the certificate:

```bash
sudo /snap/bin/certbot --nginx -d dashboard.example.com --redirect
```

Use your own domain. Follow the prompts for your email and the service terms. An existing non-snap installation normally uses `sudo certbot` instead of `sudo /snap/bin/certbot`.

{% hint style="warning" %}
Certbot updates the Nginx file to enable HTTPS and redirect HTTP visitors. **Do not paste the original Step 5 configuration over the updated file afterward.**
{% endhint %}

The certificate check needs your domain to reach this server on port `80`. If it fails, check DNS, any `AAAA` record, and both provider and server firewalls. [Let's Encrypt HTTP validation](https://letsencrypt.org/docs/challenge-types/#http-01-challenge).

Check Nginx and certificate renewal:

```bash
sudo nginx -t
sudo /snap/bin/certbot renew --dry-run
```

The snap installation schedules renewal automatically. Resolve any dry-run failure before relying on it.

{% hint style="success" %}
**Ready to continue:** `https://dashboard.example.com` opens without a certificate warning, and opening the HTTP address takes you to HTTPS.
{% endhint %}
{% endstep %}

{% step %}

## Test signing in, saving, and signing out

1. Open the public **HTTPS** address in a fresh private browser window.
2. Sign in with Discord.
3. Open a server you manage.
4. Make a small dashboard change you can undo, save it, and confirm it persists after refreshing.
5. Undo the test change if appropriate.
6. Sign out, then sign in again.

If these actions work, the setup is complete.
{% endstep %}
{% endstepper %}

## If something still does not work

| Problem                                     | Check                                                                                                                     |
| ------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- |
| `502 Bad Gateway`                           | Drako is running; its port matches `proxy_pass`; the local HTTP test returns dashboard HTML.                              |
| `426 Upgrade Required`                      | Confirm which process owns the configured port. This response alone does not establish a certificate problem.             |
| Discord redirect error                      | The Discord redirect and any explicit Drako redirect setting exactly match the public HTTPS callback.                     |
| Login returns to the login page             | Check `Hosting: "direct"`, Nginx's `X-Forwarded-Proto` line, and the active settings source.                              |
| “This session could not verify the request” | The browser's origin must match Drako's HTTPS URL. Restart after configuration changes, then test a fresh private window. |
| Works until the terminal closes             | Run Drako through your normal persistent process manager; Nginx does not keep the bot running.                            |

If Nginx is in another container or on another server, use the [Pelican and Docker guide](broken://pages/e7af9fb80e6f3d1541b4a5dc2c2b1f1fb22977eb) for the correct destination and proxy trust settings. This page's loopback settings assume both programs run directly on the same machine.

### Existing advanced settings

Older guides may have asked you to add `Host`, `TrustLoopbackProxy`, or `TrustedProxies`. Their `.env` equivalents are `DASHBOARD_HOST`, `DASHBOARD_TRUSTLOOPBACKPROXY`, and `DASHBOARD_TRUSTEDPROXIES`.

For the exact setup on this page, back up your configuration and remove those old overrides so `Hosting: "direct"` can choose the defaults. Keep custom settings if your host requires them; ask the host before changing a setup that differs from this guide.

When asking for support, include the public dashboard address, dashboard port, local HTTP test result, relevant startup error, and Nginx site configuration. Remove credentials, cookies, tokens, license keys, and session secrets before sharing.
