DEV Community

oluwatimileyin adediwura
oluwatimileyin adediwura

Posted on

Configuring NGINX web server on amazon EC2 : My Experience

Introduction

Hello 🤩, everyone. Being part of the HNG DevOps internship program, I was tasked with configuring NGINX on a fresh Ubuntu server to serve a custom HTML page. I began working on this project on January 29th, 2025, and was able to complete it after several trials.

Objective

The objective of this blog post is to illustrate how to set up and configure a basic web server on Ubuntu. Here's my approach to the task.

Configuring an EC2 instance

I created an Amazon EC2 Instance on AWS. I chose AWS Cloud Services because I was able to use the basic support plan which was free. I used the following options:

  • Ubuntu 22.04 LTS AMI (Amazon Machine Image).

  • t3.micro instance.

  • Enabled SSH (port 22) and access from anywhere (0.0.0.0/0) by configuring security settings.

  • Generated an SSH key pair to connect to my instance securely.

  • Then, launched my instance.

Connecting to the Instance, Installing and Configuring NGINX

  • After my EC2 Instance's state changed to 'Running', I connected it to the EC2 Instance Connect and began installing NGINX.

EC2 instance connect

  • To install NGINX, I use the following commands:
sudo apt update
sudo apt install nginx -y 
sudo systemctl start nginx 
sudo systemctl enable nginx
Enter fullscreen mode Exit fullscreen mode
  • To add HTML content to my web server, I used the vi editor. 'vi' allowed me to add a message that included both my name and slack username.
sudo vi /var/www/html/index.html
Enter fullscreen mode Exit fullscreen mode
  • I exited vi editor and restarted NGINX with the following commands:
sudo systemctl restart nginx
sudo systemctl status nginx
Enter fullscreen mode Exit fullscreen mode

Restarting and checking the status of nginx

  • I navigated to the public IPv4 address in a web browser, verifying that my custom message was displayed.

Displaying the HTML content
Challenges and Solutions Presented

The web server was inaccessible after I copied its IPv4 address to a web browser. I had to configure my security group to allow traffic from anywhere on port 80, which got the job done.

How This Task contributed to My Learning and Professional Objectives

My understanding of networking, cloud infrastructure, and server administration has been improved by completing this task. It was an important step in my path to becoming a DevOps engineer. Working hands-on with AWS and NGINX helped me enhance my troubleshooting skills and expand my knowledge of cloud-based deployments.

References

Devops Engineers
Cloud Engineers
Site Reliability Engineers
Platform Engineers
Infrastructure Engineers

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)