DEV Community

Cover image for Configuring NGINX web server on amazon EC2
Essa-h
Essa-h

Posted on

Configuring NGINX web server on amazon EC2

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 31st, 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.
    Image description

  • To install NGINX, I use the following commands:
    Image description

  • 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.
    Image description

  • I exited vi editor and restarted NGINX with the following commands:
    Image description

Image description

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

Image description

Challenges and Solutions

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.

Top comments (0)