Nginx Configuration
Configure Drako Tickets to run on your own domain with Nginx, HTTPS, and PM2.
Prerequisites
Before continuing, make sure that:
Drako Tickets has been uploaded to an Ubuntu or Debian server.
You have a user with
sudoaccess.Ports
80and443are 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
lsYour directory may have a different name. Update /var/www/drako-tickets in the commands below if needed.
Create the DNS Record
Create an A record with your DNS provider:
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.comInstall Drako Tickets Dependencies
Change to the directory that contains the Drako Tickets package.json file:
cd /var/www/drako-tickets
npm cIf the application has not been configured yet, create its environment file:
cp .env.example .env
nano .envKeep 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=443APP_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.
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" -- startThe 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:3000Press 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 startuppm2 startup prints one additional command beginning with sudo. Copy and run that exact command, then run pm2 save once more.
Create the Nginx Configuration
Create a site configuration for your domain:
sudo nano /etc/nginx/sites-available/tickets.example.comAdd 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.
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 nginxDo 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.
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/certbotRequest the certificate and let Certbot update the Nginx configuration:
sudo certbot --nginx -d tickets.example.comWhen prompted, enable the redirect from HTTP to HTTPS. Then test automatic certificate renewal:
sudo certbot renew --dry-runVerify the Installation
Open the following address in your browser:
https://tickets.example.comYou can also check each service from the command line:
pm2 status
sudo systemctl status nginx --no-pager
curl -I https://tickets.example.comYour Drako Tickets installation should now be available securely on your domain.
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 saveThe 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:
Emails, OAuth callbacks, or Discord links use the wrong URL
Confirm these values in /var/www/drako-tickets/.env, then restart the service:
View application or Nginx logs
Useful References
Last updated