As a DevOps Engineer, one of the first things you should learn is how to run applications on a server, using webservers like Nginx or Apache. These tools are essential for serving web content, managing traffic, and ensuring your applications are accessible to users. In this article, I will walk you through configuring Nginx to serve applications, a critical skill for anyone starting their DevOps journey.
Nginx is a web server that helps handle traffic loads while maintaining low resource usage, it can also function as a reverse proxy, load balancer, and HTTP cache.
Technical Architecture
Requirements
- Linux Server
- SSH key
- Nginx
- Web Application Code
Steps
Create a Linux Server on any cloud provider of your choice, for this article, I used the AWS cloud provider and launched an EC2 instance running on Ubuntu Server 24.04 LTS.
When the instance is provisioned, ssh into the instance following these steps;
mv keys.pem ~/.ssh
chmod 400 ~/.ssh/keys.pem
ssh -i ~/.ssh/keys.pem ubuntu@<server-ip>
- The next thing I did was to update the packages and install NGINX on the server using these commands;
sudo apt update
sudo apt install nginx -y
- I then moved to the directory my application will be running in to edit the code using these commands;
cd /var/www/html
sudo nano index.html
- Nginx configuration files are located in this directory '/etc/nginx/' in this file 'nginx.conf', but we will be using the configuration of the file in this directory '/etc/nginx/sites-available/default'
cd /etc/nginx/sites-available
sudo nano default
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
</head>
<body>
<h1>Welcome to DevOps Stage 0 -_ [Your Name]/[SlackName]</h1>
</body>
</html>
- I used these commands to ensure nginx is enabled and running on the server;
sudo systemctl start nginx
sudo systemctl enable nginx
sudo systemctl status nginx
- Then to ensure my application was running properly on the server, I went to the IP address of the server
http://<your-server-ip>/
Personal Growth
This task was pretty straightforward for me and I'll say the only challenge I faced was writing this article, I sort of overthought how I'd approach writing this article, but after doing a bit of research and reading some other people's articles, I found my direction and wrote it confidently. At the end of the day, it's all about how you approach a problem, break it down, and find the right way to solve it. This experience reinforced the importance of adaptability and learning from others while staying true to my thought process.
Looking to Hire the Best Engineers
HNG connects companies with the best engineers suited to their needs. Looking for top-tier talent to handle your DevOps, cloud infrastructure, and CI/CD tasks, HNG has the best developers available for hire and freelance jobs anywhere in the world.
Explore specialized talents available for hire:
DevOps Engineers
Cloud Engineers
Top comments (6)
Great One Dipe
Thank you
π―
Keep it up πͺπΎ
Thanks
Wonderfully written β¨π
Looking forward to your next
Thank youππ½ππ½