🚀Deployed a web application using an Nginx server within a Docker container.
🚀Configured a reverse proxy with Nginx to act as a gateway between outside requests and the application server.
🚀Set up a DNS subdomain to make the application accessible to users.
🚀Used popular tech stack including Amazon EC2, GitHub, Docker, Nginx.
🚀This project was a great learning experience for deploying web applications using the Nginx server within a Docker container.
Clone the Project repo:
git clone https://github.com/sanket363/Nginx-project.git
note :- Add inbound traffic rules for HTTP, and HTTPS in addition to SSH.
Update your package index:
sudo apt-get update
Install NGINX using apt-get:
sudo apt-get install nginx
Once the installation is complete, start the NGINX service:
sudo systemctl start nginx
To verify that NGINX is running, check its status:
sudo systemctl status nginx
You should see output indicating that the service is active and running.
NGINX should start automatically after a reboot. To enable this, run:
sudo systemctl enable nginx
Step 5: Installation and configuration files of the Nginx server can be seen at /etc/nginx path where
Install Docker using apt-get:
sudo apt-get install docker.io
Add your current user to the docker group:
sudo usermod -aG docker $USER
Reboot the system to apply the changes:
sudo reboot
Images:
Navigate to the directory that contains your Dockerfile and run the following command to build the container:
sudo docker build -t my-notes-app:latest .
To run the container and map port 8000 on the container to port 8000 on the host, run the following command:
sudo docker run -p 8000:8000 my-notes-app:latest
Images:
NGINX's configuration files are located in the /etc/nginx/ directory. The main configuration file is nginx.conf. Before making any changes to this file, make a backup copy:
sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
To apply any changes you make to the configuration files, you'll need to restart NGINX:
sudo systemctl restart nginx
To add a proxy pass configuration for your Docker container, navigate to the sites-enabled path on Ubuntu:
cd /etc/nginx/sites-enabled/
Use the following command to open the default file in Vim:
sudo vim default
Find the location /
block and inside the curly braces, add the following line to create a proxy pass to your Docker container:
proxy_pass http://127.0.0.1:8000;
Add another location
block for proxy the API requests to the container:
location /api {
proxy_pass http://127.0.0.1:8000/api;
}
Images:
After saving above changes in default file now navigate to the /var/www/html/ location and do below commands:
mkdir static
cp -r /home/<your-user>/Nginx-project/mynotes/build/static/* /var/www/html/static/
Iamges:
systemctl restart nginx
Now navingate to your browser and go to the url
http://<public-ip>/
The technology stack used in this project included Amazon EC2, GitHub, Docker, and Nginx. Amazon EC2 provided the virtual server that hosted our application, GitHub allowed us to store and version control our application code, Docker allowed us to package and deploy our application in a containerized environment, and Nginx provided the web server and reverse proxy functionality.