Member-only story
Debugging EC2 Web Server Behind an Application Load Balancer: A Tale of Gotchas
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