Deployed an E-Commerce website like the Aquila MERN Application on AWS with a Three-Tier Architecture
Step 1: Setting Up VPC, Subnets, route table and NAT Gateway, internet gateway
I created a Virtual Private Cloud (VPC) in the us-east-1 region.
I have created two subnets within the VPC, including a public subnet for the Web-Tier(public) and private subnets for the Application-Tier and Database-Tier
I created route tables: one public and two private. Private route tables were associated with private subnets, and the public route table was associated with the public subnet.
created an internet gateway for public subnets and a NAT Gateway for private subnets.
Step 2: Configuring Security Groups
I created new 3 EC2 instances. –
I chose an Ubuntu Amazon Machine Image (AMI) and selected an instance type (t2.medium)
In the instance configuration, I selected my VPC and chose a private subnet for the Application-Tier. And database-tier and in this disable public Ip because it’s private instance
Then I create web-tier server it is public server that’s why I choosed for this same vpc and public subnet and enable ip address
reviewed and launched the instances, creating a new key pair or using an existing one.
I launched the instances.
Step 3: I connected to the web-Tier EC2 instance using SSH. — Once connected, I updated the system’s package list then change keyring to connect private server using public server and connect private server application -tier and database -tier simentinesouly
Step 5: Installation
connected to the Database-Tier EC2 instance using SSH.
installed MongoDB on datatbase server and connect to public serber (web-tier)
connected to the Database-Tier EC2 instance using SSH.
installed MongoDB on datatbase server and connect to public serber (web-tier)
I have installed docker on both application-tier and database-tier
install Nginx on public server(web-tier)
mongod command
sudo apt-get update
sudo apt-get install gnupg curl
curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \
sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg \
--dearmor
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.lis
sudo apt-get install -y mongodb-org
sudo echo $?
sudo service mongod start
sudo systemctl status mongod.service
Docker installation
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt update
sudo apt install docker.io
docker --version
docker ps
sudo usermod -aG docker $USER
sudo reboot
docker ps
Ngnix installation
sudo apt update
sudo apt install nginx
sudo systemctl start nginx
sudo systemctl enable nginx
for reverse proxy commands
sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
sudo nano /etc/nginx/nginx.conf
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://localhost:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
sudo nginx -t
sudo systemctl reload nginx
step 6: Attach load balance for hiding public ip address
creat load balance attach secruity group and target group
Done!
check the ur copy DNS name paste on browser
Thanks for reading
I hope found this useful?
If you found this guide is useful and helpful then please do click on the button and also feel free to drop a comment
✅Reshare this with others so that it helps more people
✅Tag your colleagues and friends who you think will need this