DEV Community

Cover image for HNG Internship "DevOps Stage 0 - NGINX Configuration"
Precious Ogundipe
Precious Ogundipe

Posted on • Edited on

HNG Internship "DevOps Stage 0 - NGINX Configuration"

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

hng_task_0

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>
Enter fullscreen mode Exit fullscreen mode
  • 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
Enter fullscreen mode Exit fullscreen mode
  • 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
Enter fullscreen mode Exit fullscreen mode
  • 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
Enter fullscreen mode Exit fullscreen mode
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
</head>
<body>
<h1>Welcome to DevOps Stage 0 -_ [Your Name]/[SlackName]</h1>
</body>
</html>
Enter fullscreen mode Exit fullscreen mode
  • 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
Enter fullscreen mode Exit fullscreen mode
  • Then to ensure my application was running properly on the server, I went to the IP address of the server
http://<your-server-ip>/
Enter fullscreen mode Exit fullscreen mode

picture

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)

Collapse
 
chisomjude profile image
Godstime Chisom

Great One Dipe

Collapse
 
dipe_ profile image
Precious Ogundipe

Thank you

Collapse
 
hammed_bankole_4db357cdc0 profile image
Hammed Bankole

πŸ’―
Keep it up πŸ’ͺ🏾

Collapse
 
dipe_ profile image
Precious Ogundipe

Thanks

Collapse
 
tony_uketui_6cca68c7eba02 profile image
Tony Uketui

Wonderfully written βœ¨πŸ™Œ

Looking forward to your next

Collapse
 
dipe_ profile image
Precious Ogundipe

Thank youπŸ™πŸ½πŸ™πŸ½