Deployment¶
This guide covers deploying the License Key Server on a fresh AWS EC2 instance. The server requires Node.js 20 and PM2 to keep it running after SSH sessions end.
Step 1 — Launch an EC2 instance¶
- Go to EC2 → Launch Instance in the AWS Console.
- Choose Ubuntu Server 22.04 LTS (free tier eligible).
- Instance type: t3.micro (or t2.micro for free tier).
- Key pair: select your existing
.pemfile or create a new one. - Under Network settings → Edit, add inbound rules:
- HTTP, port 80, Source: 0.0.0.0/0 (or restrict to your IP range)
- SSH, port 22, Source: My IP
- Launch and note the Public IPv4 address.
Step 2 — Upload the server files¶
From your local machine, SCP the license-server folder to the EC2 instance:
scp -i /path/to/your-key.pem -r /path/to/license-server ubuntu@<EC2-PUBLIC-IP>:~/calibration-guard-web
Or clone from your repo:
ssh -i /path/to/your-key.pem ubuntu@<EC2-PUBLIC-IP>
git clone <your-repo-url> calibration-guard-web
Step 3 — Install Node.js¶
SSH into the instance:
ssh -i /path/to/your-key.pem ubuntu@<EC2-PUBLIC-IP>
Install Node.js 20 via nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install 20
nvm use 20
node -v # should print v20.x.x
Step 4 — Install dependencies¶
cd ~/calibration-guard-web
npm install
Step 5 — Start with PM2¶
Install PM2 globally:
npm install -g pm2
Start the server on port 80 with your credentials:
PORT=80 AUTH_USER=admin AUTH_PASS=yourSecurePassword pm2 start server.js --name calibguard
Save and configure startup on reboot:
pm2 save
pm2 startup # run the command it prints (starts with "sudo env PATH=...")
Step 6 — Verify¶
Open a browser and go to http://<EC2-PUBLIC-IP>. A browser login prompt will appear. Enter the credentials you set in Step 5.
License Key Server login prompt
Updating credentials¶
pm2 stop calibguard
PORT=80 AUTH_USER=admin AUTH_PASS=newPassword pm2 start server.js --name calibguard
pm2 save
Useful PM2 commands¶
pm2 status # show running processes and uptime
pm2 logs calibguard # tail live logs
pm2 restart calibguard # restart the process
pm2 stop calibguard # stop the process
Optional: HTTPS with a custom domain¶
If you have a domain pointing to the EC2 IP:
-
Install nginx and Certbot:
sudo apt update && sudo apt install -y nginx certbot python3-certbot-nginx -
Create
/etc/nginx/sites-available/calibguard:server { listen 80; server_name your-domain.com; location / { proxy_pass http://localhost:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } } -
Enable and reload:
sudo ln -s /etc/nginx/sites-available/calibguard /etc/nginx/sites-enabled/ sudo nginx -t && sudo systemctl reload nginx -
Get a free SSL certificate:
sudo certbot --nginx -d your-domain.com -
Change PM2 to run on port 3000 (nginx handles 80/443):
pm2 stop calibguard PORT=3000 AUTH_USER=admin AUTH_PASS=yourPassword pm2 start server.js --name calibguard pm2 save