AWS EC2
This guide walks you through deploying your DeploySolo app on AWS EC2 with Caddy for automatic HTTPS.
1. Launch an EC2 Instance
- AMI: Ubuntu Server 22.04 LTS (free tier eligible)
- Instance Type: t2.micro (or larger for production)
- Security Group: Allow inbound traffic on ports
22(SSH),80(HTTP), and443(HTTPS) - Key Pair: Create or select an existing SSH key pair and download the
.pemfile
2. Connect to Your Instance
chmod 400 your-key.pem
ssh -i your-key.pem ubuntu@your-ec2-public-ip
3. Install Dependencies
# Update system and install Go and Caddy
sudo apt update && sudo apt upgrade -y
sudo apt install -y golang-go caddy git
4. Deploy Your App
# Clone your repository
git clone https://github.com/yourusername/your-deploysolo-app.git
cd your-deploysolo-app
# Set environment variables
cp .env.example .env
nano .env # Add your production values (Stripe keys, domain, etc.)
# Build the app
go build -o app .
5. Configure Caddy
Create a Caddyfile at /etc/caddy/Caddyfile:
sudo nano /etc/caddy/Caddyfile
Add this configuration (replace yourdomain.com with your actual domain):
yourdomain.com {
reverse_proxy localhost:8090
}
Restart Caddy:
sudo systemctl restart caddy
Caddy will automatically provision an SSL certificate from Let’s Encrypt.
6. Run Your App as a Service
Create a systemd service file:
sudo nano /etc/systemd/system/deploysolo.service
Add this configuration (adjust paths as needed):
[Unit]
Description=DeploySolo App
After=network.target
[Service]
Type=simple
User=ubuntu
WorkingDirectory=/home/ubuntu/your-deploysolo-app
ExecStart=/home/ubuntu/your-deploysolo-app/app serve --http=127.0.0.1:8090
Restart=always
RestartSec=5
Environment="PATH=/usr/local/go/bin:/usr/bin:/bin"
[Install]
WantedBy=multi-user.target
Enable and start the service:
sudo systemctl daemon-reload
sudo systemctl enable deploysolo
sudo systemctl start deploysolo
sudo systemctl status deploysolo
7. Point Your Domain
In your domain registrar’s DNS settings, create an A record pointing to your EC2 instance’s public IP address. Wait for DNS propagation (usually 5-30 minutes).
8. Verify
Visit https://yourdomain.com in your browser. You should see your DeploySolo app running with automatic HTTPS.
Troubleshooting
- Check app logs:
sudo journalctl -u deploysolo -f - Check Caddy logs:
sudo journalctl -u caddy -f - Verify ports:
sudo netstat -tlnp | grep :8090 - Security group: Ensure ports 80 and 443 are open in your EC2 security group