DEV Community

Alao Abdul-zahir
Alao Abdul-zahir

Posted on

My Experience Setting Up NGINX on Ubuntu in AWS – HNG DevOps Stage 0

NGINX Web Server Setup on Ubuntu EC2 Instance

As part of my DevOps Stage 0 task, I set up an NGINX web server on an Ubuntu EC2 instance in AWS to serve a custom HTML page. This project allowed me to revisit foundational DevOps practices and cloud infrastructure management.

1. Launch an EC2 Instance:

I created an Ubuntu 24.04 instance using the t2.micro type and configured security groups to allow SSH (port 22) and HTTP (port 80) traffic.
Image description

2. Connecting and Setting Up:

After connecting via SSH with the .pem key, I updated the package list and installed NGINX with:

sudo apt install nginx -y
Enter fullscreen mode Exit fullscreen mode

I started and enabled NGINX to run on boot with:

sudo systemctl start nginx
sudo systemctl enable nginx
Enter fullscreen mode Exit fullscreen mode

3. Configuring the Custom HTML Page:

I replaced the default page by editing:

/var/www/html/index.html
Enter fullscreen mode Exit fullscreen mode

with my custom message and restarted NGINX to apply the changes:

Image description

sudo systemctl restart nginx
Enter fullscreen mode Exit fullscreen mode

4. Testing the Setup:

I accessed the server via its public IP and verified that the page loaded correctly in a browser.

Image description

Insights and Challenges:

  • Cloud Infrastructure: Launching EC2 instances and configuring security groups enhanced my understanding of cloud computing basics.
  • Linux Administration: Navigating Ubuntu and managing NGINX solidified my skills in Linux server management.
  • Networking: Understanding how security groups and firewalls work in cloud platforms was key to resolving issues with HTTP traffic access.

Challenges Encountered:

I initially faced issues accessing the page via the public IP due to incorrect inbound traffic configuration. Once I allowed HTTP traffic on port 80, the problem was resolved.


Conclusion:

This task was foundational for cloud infrastructure, web server configuration, and Linux system management. It’s a critical skill for any DevOps engineer and has prepared me for more advanced topics such as automation and multi-region deployments.


References:

Top comments (0)