Configuring Nginx On Amazon EC2

Hi!.
In today’s article, I will be walking through the steps to install and configure Nginx on Amazon EC2 using the Ubuntu Server. This is the first task of my HNG DevOps Internship and I am to serve a custom HTML page that shows my name and Slack use…


This content originally appeared on DEV Community and was authored by Success John

Hi!.
In today's article, I will be walking through the steps to install and configure Nginx on Amazon EC2 using the Ubuntu Server. This is the first task of my HNG DevOps Internship and I am to serve a custom HTML page that shows my name and Slack username.

Setting Up Ubuntu On Amazon EC2.

  • The first step is to create an EC2 instance using the Ubuntu AMI.
  • Instance Type: An instance type specifies the hardware to be used for the instance. I used the t2 micro instance type since it is free tier eligible.
  • Security Group: A security group is a set of firewall rules that control the traffic for my instance.
  • Key Pair: To securely connect to my instance.

After creating The EC2 Instance and it is up and running, I am able connect to the EC2 Instance and start the Nginx installation process.

To install Nginx, I used these commands:

sudo apt update
sudo apt install nginx -y 
sudo systemctl start nginx 
sudo systemctl enable nginx

After enabling nginx, I added my name and Slack username to the HTML file using the vi editor.

sudo vi /var/www/html/index.html

After saving the HTML file, I had to reboot Nginx so that I could get the new changes with these commands:

sudo systemctl restart nginx
sudo systemctl status nginx

To verify that the custom HTML Page has been rendered on my browser, I navigated to the IPv4 address generated by AWS for the instance in my web browser.

Image description

Challenges

I was opening the IP address link directly from AWS and by default it was an HTTPS address and I kept having the "CONNECTION_REFUSED" error on my browser. I later discovered that Nginx default config is HTTP only and i had to force my browser to use HTTP.

How this task contributes to my learning and professional goals.
Working on this task has helped me enhance my troubleshooting skills. in a bid to understand the issue with the connection refused error on my browser, I was able to learn more about networking.

Devops Engineers
Cloud Engineers


This content originally appeared on DEV Community and was authored by Success John


Print Share Comment Cite Upload Translate Updates
APA

Success John | Sciencx (2025-02-01T20:36:06+00:00) Configuring Nginx On Amazon EC2. Retrieved from https://www.scien.cx/2025/02/01/configuring-nginx-on-amazon-ec2/

MLA
" » Configuring Nginx On Amazon EC2." Success John | Sciencx - Saturday February 1, 2025, https://www.scien.cx/2025/02/01/configuring-nginx-on-amazon-ec2/
HARVARD
Success John | Sciencx Saturday February 1, 2025 » Configuring Nginx On Amazon EC2., viewed ,<https://www.scien.cx/2025/02/01/configuring-nginx-on-amazon-ec2/>
VANCOUVER
Success John | Sciencx - » Configuring Nginx On Amazon EC2. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/02/01/configuring-nginx-on-amazon-ec2/
CHICAGO
" » Configuring Nginx On Amazon EC2." Success John | Sciencx - Accessed . https://www.scien.cx/2025/02/01/configuring-nginx-on-amazon-ec2/
IEEE
" » Configuring Nginx On Amazon EC2." Success John | Sciencx [Online]. Available: https://www.scien.cx/2025/02/01/configuring-nginx-on-amazon-ec2/. [Accessed: ]
rf:citation
» Configuring Nginx On Amazon EC2 | Success John | Sciencx | https://www.scien.cx/2025/02/01/configuring-nginx-on-amazon-ec2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.