How I Built a Highly Available Website on AWS Using EC2, NGINX, ALB, Auto Scaling and EFS

What happens when a server hosting a company's website suddenly becomes unavailable?

Will the website stop working immediately, or can another server continue handling requests while the problem is being resolved?

These are important questions in cloud computing and DevOps because keeping an application available is just as important as deploying it successfully.

In one of my recent practical projects, I explored these questions by deploying a clinic-themed website on AWS. I obtained the website template from ThemeWagon and configured an AWS environment that included two web servers, an Application Load Balancer, an Auto Scaling group, Amazon EFS, Route 53, and other networking components.

My objective was to understand how the different parts of a cloud-hosted environment work together and how redundancy can help reduce the impact of individual server failures.

Rather than simply launching an EC2 instance and making a website accessible, I wanted to understand more about the infrastructure behind a production-style deployment.

The website is accessible through my custom subdomain:

Live demonstration: https://clinic.sirvickcloud9.online (will soon be terminated because of AWS billing)

In this article, I'll walk through the project, explain the purpose of the AWS services I used, and share the lessons I learned while exploring high availability and web infrastructure.

As always, this is a practical learning project. I am documenting my experience to strengthen my understanding of cloud infrastructure and help other beginners learn alongside me.

1. Project Overview

The main objective was to deploy a website on AWS while exploring how a multi-server environment can support availability.

I started with a clinic-themed website template from ThemeWagon. I then worked on the infrastructure needed to host the website and make it accessible through a custom subdomain.

The project brought together several AWS services and networking components.

Infrastructure components

ComponentPurpose in the project
Amazon EC2Provides the virtual servers used to host the website and support administration.
NGINXServes the website from the web servers.
Application Load Balancer (ALB)Distributes incoming requests across registered web-server targets according to its configuration and health checks.
Target groupRegisters the web servers and defines how the load balancer routes requests to them.
Auto Scaling groupManages EC2 instance capacity according to its configured settings and scaling or replacement conditions.
Amazon EFSProvides shared file storage that can be mounted by multiple EC2 instances.
Bastion serverProvides an administrative entry point to the environment, depending on the network and access configuration.
Amazon Route 53Provides DNS functionality for directing domain requests to the appropriate destination.
Internet GatewayEnables internet connectivity for resources with appropriate routing and security configuration.
NAT GatewayAllows resources in a suitably configured private subnet to initiate outbound connections to supported destinations without requiring direct inbound internet connectivity.
Security groupsControl permitted inbound and outbound traffic for the associated AWS resources.
Route tablesDetermine how traffic is routed from the associated subnets.

The infrastructure included four security groups and two route tables, alongside an Internet Gateway and a NAT Gateway.

Each component has a different responsibility. The goal of the architecture is to make those components work together rather than depend on a single server to perform every task.

2. The Website I Deployed

The website itself uses a clinic-themed design obtained from ThemeWagon.

The template provided a starting point for the user interface, including the navigation menu, healthcare-themed landing page, and appointment section.

My focus was on deploying the website within my AWS environment and understanding the infrastructure supporting it.

Screenshot: My Deployed Clinic Website


Clinic-themed website deployed on AWS EC2 using NGINX and accessed through a custom subdomain

Figure 1: The clinic-themed website deployed on AWS EC2 and accessible through my custom subdomain.


The screenshot shows the website loading through HTTPS. The current page still contains sample text and placeholder contact details from the template, so it should be treated as a demonstration website rather than the official website of a real clinic.

3. Obtaining the Website Template

I obtained the website template from ThemeWagon, a platform offering free and premium website templates.

Using a pre-designed template allowed me to focus on the deployment and infrastructure rather than building the entire interface from scratch.

However, downloading a template is only the beginning of a deployment project.

The files still need to be placed in an appropriate hosting environment. The web server must be configured to serve them, and the required network and domain settings must be in place before visitors can access the website.

For this project, the template provided the presentation layer, while the AWS environment provided the hosting infrastructure.

Before using a template publicly, it is important to check the specific template's licence and attribution requirements.

4. Hosting the Website on EC2 with NGINX

Amazon EC2 provided the virtual server environment for the web-hosting component of my project.

I configured two web servers, which I refer to as Server 1 and Server 2. NGINX was used to serve the website.

NGINX is a web server commonly used to deliver static content, such as HTML pages, stylesheets, JavaScript files, and images. It can also operate as a reverse proxy for applications.

In a typical Ubuntu environment, NGINX can be installed using:

sudo apt update
sudo apt install nginx -y

Its service status can be checked with:

sudo systemctl status nginx

These are standard Ubuntu commands; the actual commands used in a deployment should reflect the steps performed on the servers.

After preparing the web servers, the website files need to be placed in the appropriate directory, and NGINX must be configured to serve the correct content.

This part of the project reinforced an important lesson: launching an EC2 instance does not automatically make a website accessible. The web server, website files, networking, and related configurations must work together.

5. Using an Application Load Balancer and Target Group

One of the important components of this project was the AWS Application Load Balancer.

When a website is hosted on a single server, that server becomes a critical dependency. If it stops responding, the website may become unavailable until the problem is resolved.

Using two web servers creates the possibility of distributing requests across more than one server.

However, visitors need a way to reach the available servers without having to choose an individual server themselves.

This is where the Application Load Balancer comes in.

How the load balancer works

In a typical configuration, the request flow looks like this:

  1. A visitor opens the website.

  2. DNS directs the request to the configured destination.

  3. The Application Load Balancer receives the request.

  4. The load balancer evaluates its registered targets and health-check results.

  5. It routes eligible requests to healthy targets according to its listener rules and routing configuration.

  6. The selected web server processes the request and returns the response.

The target group contains the registered targets to which the load balancer can route traffic.

In my project, the target group was configured for the two web servers.

Why is this important?

Imagine that Server 1 becomes unhealthy while Server 2 remains operational.

With suitable target-group health checks and load-balancer configuration, the load balancer can stop routing new requests to Server 1 and continue sending eligible requests to Server 2.

This can reduce the impact of the failure on website visitors.

However, the actual result depends on the health-check settings, the application, network connectivity, and the capacity of the surviving server.

The important lesson is that multiple servers provide redundancy, while the load balancer provides a mechanism for directing traffic to available targets.

Having two EC2 instances alone does not automatically provide this behaviour.

6. Using Auto Scaling to Manage EC2 Capacity

Another component of the project was an Auto Scaling group.

AWS Auto Scaling helps manage the number of EC2 instances according to the group's configuration, including its minimum, maximum, and desired capacity.

For example, an Auto Scaling group may be configured to maintain a desired number of web-server instances.

If an instance is terminated or becomes unhealthy under the applicable health-check configuration, Auto Scaling can launch a replacement when the group's settings and conditions call for it.

This is useful because an environment should not necessarily depend on an administrator manually creating a new instance every time a server fails.

It is important to understand the difference between Auto Scaling and load balancing.

  • Auto Scaling manages instance capacity and can replace instances under the configured conditions.

  • The Application Load Balancer routes requests to registered targets according to its listener rules and health checks.

  • The target group identifies the targets that receive traffic and defines their health-check configuration.

These components can complement one another.

For example, the load balancer may stop sending requests to an unhealthy server, while Auto Scaling works to restore the configured instance capacity.

The exact behaviour depends on how the group, health checks, launch configuration, and load balancer are integrated.

Exploring this relationship was one of the reasons I wanted to build a multi-server environment rather than simply deploy the website on a single EC2 instance.

7. Sharing Website Files with Amazon EFS

I also incorporated Amazon Elastic File System (EFS) into the project.

EFS is a managed file-storage service that allows multiple clients, including supported EC2 instances, to access a shared file system.

This is useful in environments where more than one web server needs access to the same files.

For example, if two web servers serve the same static website, shared storage can help them access a common set of website files rather than requiring completely separate copies that must be updated independently.

However, EFS must be mounted and configured correctly on the servers. Network connectivity, mount targets, security groups, file permissions, and the application's storage requirements all matter.

Shared storage also does not automatically make an application highly available. It is one component of the wider design.

For this project, EFS was an opportunity to explore how shared storage can fit into a multi-server hosting environment.

It also raised an important architectural question: which files should be shared between servers, and which files should remain local to an individual instance?

Understanding that distinction is useful when moving from a simple website deployment to more complex infrastructure.

8. Using a Bastion Server for Administrative Access

The environment also included a bastion server.

A bastion host is commonly used as a controlled entry point for administrative access to resources in a private network.

For example, an administrator may connect to the bastion host and then access private EC2 instances from there, instead of exposing direct SSH access to every server.

This can help centralise administrative access, provided the network rules and access controls are configured appropriately.

A typical design may restrict SSH access to the bastion host and permit administrative connections from the bastion to the private web servers.

The exact rules depend on the network architecture.

A bastion host is not automatically secure simply because it exists. It should have tightly controlled access, suitable security-group rules, updated software, and appropriate authentication.

In this project, the bastion server formed part of the wider infrastructure I configured around the web servers.

9. Configuring Route 53 and the Custom Subdomain

The website is accessible through:

clinic.sirvickcloud9.online

I used Route 53 as part of the project's DNS configuration.

DNS translates human-readable domain names into the destinations required for network communication.

For a website using an Application Load Balancer, a common approach is to configure the relevant Route 53 record to direct the domain or subdomain to the load balancer.

This allows visitors to access the website through a memorable hostname rather than having to enter the address of an individual EC2 instance.

It also means that visitors can use the same hostname while the load balancer routes requests to the registered web servers.

The important distinction is that DNS and load balancing serve different purposes.

Route 53 resolves the domain name, while the Application Load Balancer distributes requests to the configured targets.

Using the correct DNS destination is therefore an important part of the deployment.

10. Understanding the Internet Gateway, NAT Gateway, Route Tables, and Security Groups

The project also involved networking components that control how resources communicate with each other and with the internet.

These components are important because a working web server is not enough if the network cannot deliver requests to it.

Internet Gateway

An Internet Gateway enables internet connectivity for resources in a VPC when the appropriate routing and other requirements are satisfied.

For example, a public subnet's route table may include a route directing internet-bound traffic to the Internet Gateway.

However, attaching an Internet Gateway to a VPC does not automatically make every resource publicly accessible. Subnet routes, public addressing, security groups, and other configuration details also matter.

NAT Gateway

A NAT Gateway can allow resources in a suitably configured private subnet to initiate outbound connections to the internet without requiring those resources to accept unsolicited inbound internet connections.

For example, a private EC2 instance might need outbound access to download software updates.

A NAT Gateway is commonly used with a private-subnet route that directs the relevant outbound traffic to it.

It does not replace the Internet Gateway or automatically provide public inbound access to private instances.

Route tables

I configured two route tables as part of the networking setup.

Route tables determine where network traffic is directed from the associated subnets.

The exact routes depend on the network design. A public subnet may route internet-bound traffic through an Internet Gateway, while a private subnet may use a NAT Gateway for outbound internet access.

The routing configuration must match the intended architecture.

Security groups

The project included four security groups.

Security groups act as virtual firewalls for associated AWS resources, controlling permitted inbound and outbound traffic.

Separating security groups by role can help keep network permissions organised.

For example, a configuration may allow web traffic to the load balancer, allow the load balancer to reach the web servers on the required application port, and restrict administrative access to trusted sources.

The specific rules should reflect the actual architecture and should not allow unnecessary access.

These networking components helped me understand that cloud infrastructure is not just a collection of virtual machines. The connections and permissions between resources are equally important.

11. What Happens If One Web Server Fails?

This was the central question behind my deployment experiment.

In a production environment, a web server may become unavailable for several reasons, including an operating-system failure, a service crash, resource exhaustion, or a network problem.

A resilient design aims to reduce the impact of such failures.

In an environment like the one I explored, the components have different responsibilities:

  • The Application Load Balancer can stop routing new requests to targets identified as unhealthy.

  • The remaining healthy web server can continue serving eligible requests if the application and dependencies remain available and it has sufficient capacity.

  • Auto Scaling can launch a replacement instance when the group's configured conditions call for it.

  • EFS can provide shared files to both web servers when mounted and configured correctly.

  • Route 53 provides DNS resolution for the website's hostname.

Together, these components can help reduce dependence on a single web server.

However, this does not guarantee that users will never notice a problem. Existing connections may be interrupted, health checks take time to detect failures, and the surviving server may become overloaded.

Other dependencies can also affect availability. For example, if both web servers depend on a single unavailable component, having two web servers may not be enough to keep the whole service running.

This is why high availability requires both appropriate architecture and testing.

The objective is to reduce the likelihood and impact of an individual component failure, not to assume that failures are impossible.

12. Testing and Verifying the Deployment

Once a website has been deployed, it is important to test more than whether the landing page opens.

For the web-hosting component, useful checks include:

  • Confirming that the website opens through its custom subdomain.

  • Verifying that HTTPS works correctly.

  • Checking that the web servers are running NGINX.

  • Confirming that the target group registers the intended web servers.

  • Reviewing the target group's health-check status.

  • Checking the Auto Scaling group's desired and actual capacity.

  • Verifying that EFS is mounted and accessible where required.

  • Checking that security groups and route tables allow the intended communication.

To investigate failover, a separate controlled test can be performed in a suitable test environment.

For example, one could make a web-server target unavailable and observe whether the load balancer marks it unhealthy and continues routing eligible requests to the remaining healthy target.

The Auto Scaling behaviour could then be checked separately to determine whether the configured group launches a replacement instance.

These tests answer different questions: the load balancer's behaviour concerns traffic routing, while Auto Scaling's behaviour concerns instance capacity.

I would document the observed results rather than assume that the intended behaviour occurred simply because the resources were configured.

13. Lessons I Learned from the Project

This project helped me connect several important cloud concepts.

Multiple servers are only part of the solution

Having two web servers can provide additional capacity, but traffic must be directed to available servers, and the remaining capacity must be sufficient to handle requests.

Auto Scaling and load balancing are different

Auto Scaling manages instance capacity according to its configuration. The load balancer distributes requests to registered targets. Both can contribute to a resilient environment, but they do different jobs.

Shared storage has an important role

EFS can help multiple web servers access common files, provided the file system and application are configured to use it correctly.

Networking determines how components communicate

Internet Gateways, NAT Gateways, route tables, and security groups influence how traffic moves through the environment and which connections are permitted.

Availability requires testing

A deployment that works under normal conditions has not necessarily demonstrated how it behaves during a failure.

Testing target health, traffic routing, and instance replacement provides evidence of how the architecture behaves.

As a junior cloud and DevOps practitioner, I am still developing my skills. This is exactly why I value practical projects: they help me understand not only what each AWS service does, but also how the services work together.

14. What I Would Improve Next

There are several improvements I would consider as I continue learning.

Improve the website content: Replace the template's sample contact details and placeholder text with suitable content for a demonstration website.

Document the architecture: Create a clear diagram showing the VPC, subnets, load balancer, target group, EC2 instances, bastion host, EFS, and relevant routing components.

Test server failure: Perform a controlled test and record how the load balancer, target group, and Auto Scaling group respond.

Explore monitoring: Use suitable monitoring and logging to understand server health, resource usage, and application availability.

Explore automated deployment: Investigate how a CI/CD pipeline could publish website changes consistently without requiring manual file transfers.

These improvements would help me develop a more complete understanding of the deployment lifecycle, from hosting and networking to monitoring and recovery.

Conclusion

This project was an opportunity to explore more than basic website hosting.

I deployed a clinic-themed website using AWS EC2 and NGINX, and I worked with a broader environment involving an Application Load Balancer, target group, Auto Scaling, EFS, Route 53, a bastion server, security groups, route tables, an Internet Gateway, and a NAT Gateway.

The main lesson I wanted to explore was how these components can work together to support a more resilient hosting environment.

A web server can fail unexpectedly, so production infrastructure should be designed with that possibility in mind. Multiple web servers, health checks, load balancing, shared storage where appropriate, and automated instance replacement can all contribute to reducing the impact of individual failures.

However, reliable infrastructure requires more than configuring services. The design must be appropriate for the application, and the intended behaviour must be tested.

I am continuing to develop my cloud and DevOps skills through practical projects like this one. My goal is to understand the technology behind each deployment, document what I learn, and gradually improve my ability to build and troubleshoot cloud-hosted environments.

Thank you for reading SirVick DevOps Diary. More practical projects and lessons will follow.


Read Also: How i used Mongodb Atlas Metrics To Understand And Debug My Replica Set                      https://blog.sirvickcloud9.online/2026/10/my-app-went-down-how-i-used-mongodb-atlas-metrics-to-debug.html


Comments

Popular posts from this blog

How I Fixed GitHub Error: failed to push some refs to github.com in 2026

How I Deployed Netflix Clone (NGold) to AWS EC2 - Live at 32.196.145.76:3000 [Docker + Nginx Guide]

Understanding Linux Environment — The Real Engine Behind My AWS Cloud Deployment