Skip to content

Anonymous-message Application made with modern website and cloud native tools with AWS deployment

Notifications You must be signed in to change notification settings

Sab-429/Anonymous-message

Repository files navigation

workflow

📦 Tech Stack

Development

  • Next.js (App Router)
  • TypeScript
  • NextAuth.js
  • Resend Email API
  • MongoDB Atlas
  • Docker & Docker Compose

Deployment

  • AWS EC2 (Ubuntu 22.04)
  • Nginx (Reverse Proxy)
  • Cloudflare DNS
  • Let's Encrypt SSL (Certbot)
  • GitHub (SSH authentication)

1️⃣ Launch EC2 Instance

  • OS: Ubuntu latest(24.04)

  • Instance: ** t3.micro** (free tier)

  • Security Group:

    • SSH → 22
    • HTTP → 80
    • HTTPS → 443 all 3 ports can be accesed from anywhere

2️⃣ Connect to EC2 (Windows – Git Bash)

cd /c/Users/YourName/path-to-key
chmod 400 key.pem
ssh -i key.pem ubuntu@EC2_PUBLIC_IP

3️⃣ Update System & Install Essentials

sudo apt update && sudo apt upgrade -y
sudo apt install -y curl git unzip

4️⃣ Install Docker

sudo apt install -y docker.io
sudo systemctl start docker
sudo systemctl enable docker
sudo usermod -aG docker ubuntu
newgrp docker

Verify:

docker --version

5️⃣ Install Docker Compose

sudo apt install docker-compose -y
docker-compose --version

6️⃣ Clone Project from GitHub (SSH)

Generate key:

ssh-keygen -t ed25519 -C "ec2-deploy"
cat ~/.ssh/id_ed25519.pub

➡ Add the key to GitHub → Settings → SSH Keys

Clone repo:

mkdir ~/apps && cd ~/apps
git clone git@github.com:USERNAME/REPOSITORY.git
cd REPOSITORY

7️⃣ Environment Variables Setup

Create .env:

nano .env
NODE_ENV=production
NEXTAUTH_URL=https://subdomain.yourdomain.com
DATABASE_URL=###############################

Save: CTRL + O → Enter → CTRL + X


8️⃣ Docker Compose Configuration

services:
  app:
    build: .
    container_name: project_app
    env_file:
      - .env
    ports:
      - "3000:3000"
    restart: unless-stopped

Build & run:

docker-compose build
docker-compose up -d

Check:

docker ps

9️⃣ Install & Configure Nginx

sudo apt install -y nginx
sudo systemctl start nginx
sudo systemctl enable nginx

Create config:

sudo nano /etc/nginx/sites-available/yourapp
server {
    listen 80;
    server_name subdomain.yourdomain.com;

    location / {
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

Enable:

sudo ln -s /etc/nginx/sites-available/yourapp /etc/nginx/sites-enabled/
sudo rm /etc/nginx/sites-enabled/default
sudo nginx -t
sudo systemctl reload nginx

🔟 Cloudflare DNS Setup

Add record:

Type: A
Name: subdomain
Value: EC2_PUBLIC_IP
Proxy: ON
TTL: Auto

Verify:

ping subdomain.yourdomain.com

1️⃣1️⃣ SSL Setup (Let's Encrypt)

Install Certbot:

sudo apt install -y certbot python3-certbot-nginx

Generate certificate:

sudo certbot --nginx -d subdomain.yourdomain.com

Auto‑renew test:

sudo certbot renew --dry-run

1️⃣2️⃣ MongoDB Atlas Security

Replace:

0.0.0.0/0

With:

EC2_PUBLIC_IP/32

✔ Improves security


1️⃣3️⃣ Health & Memory Checks

free -h
docker stats
df -h

✅ Final Checklist

  • HTTPS enabled
  • HTTP → HTTPS redirect
  • Containers healthy
  • MongoDB connected
  • Nginx active
  • Certbot auto‑renew enabled
  • Cloudflare resolving correctly

About

Anonymous-message Application made with modern website and cloud native tools with AWS deployment

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages