For the complete documentation index, see llms.txt. This page is also available as Markdown.

Nginx Configuration

Configure Drako Tickets to run on your own domain with Nginx, HTTPS, and PM2.

This guide uses tickets.example.com as the example domain and /var/www/drako-tickets as the installation directory. Replace both values where necessary.

Prerequisites

Before continuing, make sure that:

  • Drako Tickets has been uploaded to an Ubuntu or Debian server.

  • You have a user with sudo access.

  • Ports 80 and 443 are open in your server or hosting-provider firewall.

  • You know the directory that contains package.json.

Check the application directory before using the commands in this guide:

cd /var/www
ls

Your directory may have a different name. Update /var/www/drako-tickets in the commands below if needed.

1

Create the DNS Record

Create an A record with your DNS provider:

Type
Host
Value

A

tickets

<SERVER_IP>

This example makes Drako Tickets available at tickets.example.com.

If you use Cloudflare, set the record to DNS only until the SSL certificate has been issued. Remove any incorrect AAAA record unless your server is also configured for IPv6.

DNS changes can take time to propagate. Confirm that the domain resolves to your server before requesting an SSL certificate:

getent hosts tickets.example.com
2

Install Nginx

sudo apt update
sudo apt install nginx curl -y
sudo systemctl enable --now nginx

If UFW is enabled, allow web traffic:

sudo ufw allow 'Nginx Full'
3

Install Drako Tickets Dependencies

Change to the directory that contains the Drako Tickets package.json file:

cd /var/www/drako-tickets
npm c

If the application has not been configured yet, create its environment file:

cp .env.example .env
nano .env

Keep your existing licence, Supabase, database, and Discord values. Set the public application address as follows:

APP_PROTOCOL=https
APP_HOST=tickets.example.com
APP_PORT=443

APP_HOST must contain only the hostname. Do not include http://, https://, a path, or a trailing slash.

Press CTRL + X, then Y, then Enter to save the file.

4

Run Drako Tickets with PM2

Install PM2 and start the application:

npm install -g pm2
cd /var/www/drako-tickets
pm2 start npm --name "drako-tickets" -- start

The production start command builds Drako Tickets and serves it on port 3000. If DISCORD_BOT_TOKEN is present in .env, the same command also starts the Discord bot.

Wait for the build to finish, then check the service and test it locally:

pm2 status
pm2 logs drako-tickets --lines 100
curl -I http://127.0.0.1:3000

Press CTRL + C to exit the logs. A response from curl confirms that the application is listening; a redirect response is also normal.

Save the PM2 process list and configure it to start after a reboot:

pm2 save
pm2 startup

pm2 startup prints one additional command beginning with sudo. Copy and run that exact command, then run pm2 save once more.

5

Create the Nginx Configuration

Create a site configuration for your domain:

sudo nano /etc/nginx/sites-available/tickets.example.com

Add the following configuration:

server {
    listen 80;
    listen [::]:80;

    server_name tickets.example.com;

    client_max_body_size 12M;

    location / {
        proxy_pass http://127.0.0.1:3000;
        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_set_header X-Forwarded-Host $host;

        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_cache_bypass $http_upgrade;
    }
}

Drako Tickets already supplies its application security headers, so they do not need to be duplicated in Nginx.

Press CTRL + X, then Y, then Enter to save the file.

6

Enable the Site

Enable the configuration and test it before reloading Nginx:

sudo ln -s /etc/nginx/sites-available/tickets.example.com /etc/nginx/sites-enabled/tickets.example.com
sudo nginx -t
sudo systemctl reload nginx

Do not reload Nginx if sudo nginx -t reports an error. Correct the file first and test it again.

Open http://tickets.example.com in a browser to confirm that Nginx can reach Drako Tickets.

7

Install the SSL Certificate

Install Certbot using the officially recommended snap package:

sudo apt install snapd -y
sudo snap install --classic certbot
sudo ln -sf /snap/bin/certbot /usr/local/bin/certbot

Request the certificate and let Certbot update the Nginx configuration:

sudo certbot --nginx -d tickets.example.com

When prompted, enable the redirect from HTTP to HTTPS. Then test automatic certificate renewal:

sudo certbot renew --dry-run
8

Verify the Installation

Open the following address in your browser:

https://tickets.example.com

You can also check each service from the command line:

pm2 status
sudo systemctl status nginx --no-pager
curl -I https://tickets.example.com

Your Drako Tickets installation should now be available securely on your domain.

9

Updating Drako Tickets

After replacing the application files with a newer release, reinstall the exact dependencies and restart the PM2 service:

cd /var/www/drako-tickets
npm ci
pm2 restart drako-tickets --update-env
pm2 save

The restart runs the production build before bringing the application back online.

Troubleshooting

Nginx shows 502 Bad Gateway

Confirm that Drako Tickets is running and listening on port 3000:

The domain does not open

Check that the DNS record points to the correct public server IP and that ports 80 and 443 are open.

Nginx configuration test fails

Inspect the error and verify the site configuration:

Confirm these values in /var/www/drako-tickets/.env, then restart the service:

View application or Nginx logs

Useful References

Last updated