This guide shows how to get a real SSL certificate from Let's Encrypt for your MaizeBus backend.
-
Get a Domain Name
- Buy a domain (e.g., from Namecheap, GoDaddy, Cloudflare)
- Point it to your EC2 instance IP:
ec2-3-129-13-199.us-east-2.compute.amazonaws.com - Example:
api.maizebus.com→ec2-3-129-13-199.us-east-2.compute.amazonaws.com
-
Add GitHub Secret
- Go to GitHub repository → Settings → Secrets and variables → Actions
- Add new secret:
DOMAIN_NAME=your-domain.com - Example:
DOMAIN_NAME=api.maizebus.com
-
Redeploy
- Push any change to trigger deployment
- Certbot will automatically get the certificate
- Nginx will be configured for HTTPS
If you prefer to set up Let's Encrypt manually:
# SSH into your EC2 instance
ssh -i your-key.pem ubuntu@ec2-3-129-13-199.us-east-2.compute.amazonaws.com
# Install certbot
sudo apt-get update
sudo apt-get install certbot python3-certbot-nginx
# Get certificate (replace with your domain)
sudo certbot --nginx -d your-domain.com --non-interactive --agree-tos --email your-email@example.com
# Test renewal
sudo certbot renew --dry-run- Sign up at cloudflare.com
- Add your domain
- Change nameservers to Cloudflare's
- Add A record:
api→ec2-3-129-13-199.us-east-2.compute.amazonaws.com
- Buy domain at namecheap.com
- Go to Advanced DNS
- Add A record:
api→ec2-3-129-13-199.us-east-2.compute.amazonaws.com
- Buy domain at godaddy.com
- Go to DNS Management
- Add A record:
api→ec2-3-129-13-199.us-east-2.compute.amazonaws.com
After getting your domain, update the frontend:
- Update config.ts:
export const API_BASE_URL = isDevelopment
? 'http://localhost:3001'
: apiUrl || 'https://your-domain.com';-
Add GitHub Secret:
EC2_API_URL=https://your-domain.com
-
Redeploy frontend
After setup, verify:
# Test HTTPS
curl https://your-domain.com/health
# Check certificate
openssl s_client -connect your-domain.com:443 -servername your-domain.comLet's Encrypt certificates expire every 90 days. The deployment includes automatic renewal:
# Check renewal status
sudo certbot certificates
# Test renewal
sudo certbot renew --dry-run
# Manual renewal
sudo certbot renew- Check domain DNS propagation:
nslookup your-domain.com - Verify EC2 Security Group has port 443 open
- Check Nginx logs:
sudo tail -f /var/log/nginx/error.log
- Wait for DNS propagation (up to 24 hours)
- Check DNS settings in your domain provider
- Use
dig your-domain.comto verify
- Ensure domain points to your EC2 IP
- Check that port 80 is open in Security Group
- Verify Nginx is running:
sudo systemctl status nginx
Make sure you have these secrets configured:
EC2_HOST=ec2-3-129-13-199.us-east-2.compute.amazonaws.com
EC2_USERNAME=ubuntu
EC2_SSH_KEY=your-private-key
DOMAIN_NAME=your-domain.com
EMAIL_USER=your-email@gmail.com
EMAIL_PASS=your-app-password
EMAIL_TO=contact@maizebus.com
EC2_API_URL=https://your-domain.com
- ✅ Free SSL certificates
- ✅ Automatic renewal
- ✅ Trusted by all browsers
- ✅ No security warnings
- ✅ Professional appearance
- ✅ Better SEO ranking
Your backend will be accessible at https://your-domain.com with a trusted SSL certificate!