Image: POC Setup in AWS

Member-only story

Debugging EC2 Web Server Behind an Application Load Balancer: A Tale of Gotchas

Niraj Kumar
7 min readJan 29, 2023

Running a webserver on Amazon Web Services (AWS) can be a complex task, especially if you’re deploying it behind a load balancer. In this blog, I’ll take a look at a recent experiment where I attempted to run an EC2 instance as a webserver behind an Application Load Balancer.

In the process, I encountered three "gotchas" - issues that tripped me up, but eventually, I figured out how to resolve them.

These gotchas are common issues that many people might face when deploying EC2 instances as webservers, so by sharing my experience, I hope to help others avoid similar mistakes.

Gotcha #1: User Script Issues

My first issue arose when I found that my user script, which was supposed to install the webserver, did not run. After some digging, I discovered that I had made a simple mistake - I had forgotten to include "#!/bin/bash" at the beginning of the script. This small oversight prevented my script from executing, and I had to manually install the webserver.
Initial User Script without #!/bin/bash

sudo yum update -y
sudo yum install -y httpd php
sudo systemctl start httpd
sudo systemctl enable httpd

--

--

Niraj Kumar
Niraj Kumar

Written by Niraj Kumar

An Enterprise Cloud Architect with a passion for helping customers design, build, and operate workloads on public cloud in a secure and robust manner.

No responses yet