1. Launch Instance
- Go to EC2 Console and click Launch Instances.
- Name:
inbox-zero(or whatever you like) - OS / AMI:
- Select Amazon Linux 2023 (Kernel 6.1 LTS).
- Instance Type:
- Test:
t2.microort3.micro(Free Tier, 1GB RAM).- Warning: You must set up swap memory (see below) or the app will crash.
- Production:
t3.medium(4GB RAM) or larger is recommended to avoid OOM kills.
- Test:
- Key Pair:
- Create a new key pair if you don’t have one.
- Name: e.g.,
inbox-zero. - Type: RSA,
.pemformat. - Permissions: Run
chmod 400 ~/.ssh/your-key.pemimmediately after downloading.
- Network Settings:
- Allow SSH traffic from Anywhere (or My IP if you have a static IP).
- Note: Using “Anywhere” is acceptable for test servers since you’re using key-based authentication. For production, consider restricting to your office IP or VPN.
- Allow HTTP/HTTPS traffic from the internet.
- Allow SSH traffic from Anywhere (or My IP if you have a static IP).
- Storage: Default (8GB) is usually fine for testing, but 20GB is safer for Docker images + logs.
2. Post-Launch Setup
Elastic IP (Recommended)
EC2 public IPs change if you stop/start the instance. For a stable address:- Go to Network & Security -> Elastic IPs.
- Click Allocate Elastic IP address.
- Select the IP -> Actions -> Associate Elastic IP address.
- Select your instance and associate.
SSH Config
Add the server to your local~/.ssh/config to avoid typing long IPs.
ssh inbox-zero-test
Essential Server Setup (Amazon Linux 2023)
Once logged in, run these commands to prepare the server.1. Update & Install Required Tools
2. Install Node.js (Required if using setup CLI)
After logging back in, install Node.js: Note: this is only needed if you want to run the setup CLI:3. Install Docker Compose
4. Setup Swap Memory (CRITICAL for Micro Instances)
If you are using at2.micro or t3.micro (1GB RAM), you MUST add swap or the build/runtime will crash.
3. SSL/HTTPS Setup
Application Load Balancer (ALB)
You can also use nginx or any approach of your choice.-
Request SSL Certificate (AWS Certificate Manager):
- Go to AWS Certificate Manager console
- Click Request certificate → Request a public certificate
- Enter your domain name (e.g.,
app.yourdomain.com) - Choose DNS validation (easier) or Email validation
- Follow validation steps: AWS will provide a CNAME record to add to your DNS. Once added, the certificate will be issued in 5-10 minutes.
- Wait for certificate status to show Issued
-
Create Target Group:
- Go to EC2 Console → Target Groups → Create target group
- Name: e.g.,
inbox-zero-web - Target type: Instances
- Protocol: HTTP, Port: 3000
- Health check path:
/api/health - Click Next, select your EC2 instance, click Include as pending below, then Next, then Create target group
-
Create Application Load Balancer:
- Go to EC2 Console → Load Balancers → Create load balancer
- Choose Application Load Balancer
- Name:
inbox-zero-alb - Scheme: Internet-facing
- IP address type: IPv4
- Network mapping: Select at least 2 availability zones
- Security groups: Create/select one that allows HTTP (80) and HTTPS (443) from anywhere
- Listeners:
- Add listener: HTTPS (443) → Forward to your target group
- (Optional) Add listener: HTTP (80) → Redirect to HTTPS
- Secure listener settings: Select your ACM certificate
- Click Create load balancer
-
Update DNS:
- Wait for the ALB to finish provisioning (status: Active, takes 2-5 minutes)
- Find the ALB DNS name in EC2 Console → Load Balancers → click your ALB → copy the DNS name
- In your DNS provider, create a CNAME record:
- Name: Your domain/subdomain (e.g.,
testfortest.yourdomain.comor@for root domain) - Target:
<ALB-DNS-name>(e.g.,inbox-zero-alb-123456789.us-east-1.elb.amazonaws.com) - Proxy status: DNS only (if using Cloudflare DNS)
- Name: Your domain/subdomain (e.g.,
-
Update Security Group:
- Your EC2 instance security group should allow traffic from the ALB security group on port 3000
- Add a new port 3000 rule with source set to the ALB’s security group (find it in ALB → Security tab)
- This allows only the ALB to access your app on port 3000, not the public internet