This guide will walk you through hosting your application on an Amazon Web Services (AWS) EC2 instance. Since your application uses a real interactive terminal (node-pty), it requires a full virtual machine environment and cannot run on serverless platforms like Vercel.
- An AWS Account (you can use the Free Tier).
- Basic familiarity with the terminal.
- Log in to AWS Console and navigate to EC2.
- Click Launch Instance.
- Name: Give your instance a name (e.g., "CyberTools-Server").
- OS Image: Choose Ubuntu Server 24.04 LTS (or 22.04 LTS). It's free-tier eligible and works great with Docker.
- Instance Type: Choose t2.micro (Free Tier eligible) or t3.micro.
- Key Pair:
- Click "Create new key pair".
- Name it (e.g., "cyber-key").
- Type: RSA.
- Format:
.pem. - Click Create key pair. The file will download automatically. Keep this safe!
- Network Settings:
- Check "Allow SSH traffic from" -> My IP (for security).
- Check "Allow HTTP traffic from the internet".
- Check "Allow HTTPS traffic from the internet".
- Click Launch Instance.
- Go to your instance dashboard and click on your new instance ID.
- Click the Security tab.
- Click the Security Group link (e.g.,
sg-01234...). - Click Edit inbound rules.
- Click Add rule:
- Type: Custom TCP
- Port range:
3000 - Source:
0.0.0.0/0(Anywhere) - Note: For production, restrict this to your IP or use a reverse proxy like Nginx.
- Click Save rules.
- Open your local terminal.
- Move your key file to a safe place (e.g.,
~/.ssh/) and restrict permissions:chmod 400 ~/.ssh/cyber-key.pem - Connect via SSH (replace
YOUR_PUBLIC_IPwith the Public IPv4 address from the EC2 dashboard):ssh -i ~/.ssh/cyber-key.pem ubuntu@YOUR_PUBLIC_IP
Once connected to the server, run these commands to install Docker:
# Update packages
sudo apt-get update
# Install Docker
sudo apt-get install -y docker.io
# Start Docker and enable it to run on boot
sudo systemctl start docker
sudo systemctl enable docker
# Add your user to the docker group (so you don't need 'sudo' for docker commands)
sudo usermod -aG docker $USERLog out and log back in for the group change to take effect:
exit
# Reconnect
ssh -i ~/.ssh/cyber-key.pem ubuntu@YOUR_PUBLIC_IPYou have two options to get your code onto the server:
If your code is on GitHub:
- Clone your repository:
git clone https://github.com/YOUR_USERNAME/YOUR_REPO.git cd YOUR_REPO
If your code is only local:
- On your local machine, run:
# Zip your project (excluding node_modules) zip -r cyber-tools.zip . -x "node_modules/*" ".git/*" # Upload to EC2 scp -i ~/.ssh/cyber-key.pem cyber-tools.zip ubuntu@YOUR_PUBLIC_IP:~/
- On the EC2 instance:
sudo apt-get install unzip unzip cyber-tools.zip -d cyber-tools cd cyber-tools
Inside your project directory on the server:
- Build the Docker image:
docker build -t cyber-tools .
Run the container with the following command. Note the --network host and --cap-add=NET_ADMIN flags, which are required for the Live Packet Analyzer to capture network traffic.
sudo docker run -d \
--name cyber-tools \
--network host \
--cap-add=NET_ADMIN \
--restart unless-stopped \
cyber-tools-appNote:
--network hostallows the container to share the host's network stack, which is necessary fortsharkto see the server's traffic.--cap-add=NET_ADMINgrants the necessary privileges to capture packets.
Open your browser and navigate to:
http://<your-ec2-public-ip>:3000
(Since we are using --network host, the app binds directly to port 3000 on the host).
You should see your Cyber Security Tools Portal, and the terminal should be fully interactive!
- View Logs:
docker logs -f cyber-app - Stop App:
docker stop cyber-app - Update App:
git pull(or upload new files)docker build -t cyber-tools .docker stop cyber-appdocker rm cyber-appdocker run -d -p 3000:3000 --restart always --name cyber-app cyber-tools