DEV Community

Cover image for 17.Haproxy LBR Troubleshooting
Thu Kha Kyawe
Thu Kha Kyawe

Posted on

17.Haproxy LBR Troubleshooting

Lab Information

xFusionCorp Industries has an application running on Nautlitus infrastructure in Stratos Datacenter. The monitoring tool recognised that there is an issue with the haproxy service on the LBR server. That needs to fixed to make the application work properly.

Troubleshoot and fix the issue, and make sure haproxy service is running on the Nautilus LBR server. Once fixed, make sure you are able to access the website by running the command curl http://stlb01:80/ in the terminal.

Lab Solutions

🧭 Part 1: Lab Step-by-Step Guidelines
Objective

Fix HAProxy service on LBR server (stlb01) and ensure:

curl http://stlb01:80/

works successfully.

1️⃣ Login to Jump Host

ssh thor@jump_host.stratos.xfusioncorp.com
Enter fullscreen mode Exit fullscreen mode

Password:

mjolnir123

2️⃣ SSH into LBR Server

ssh loki@stlb01
Enter fullscreen mode Exit fullscreen mode

Password:

Mischi3f

3️⃣ Switch to Root

sudo -i
Enter fullscreen mode Exit fullscreen mode

4️⃣ Check HAProxy Status

systemctl status haproxy
Enter fullscreen mode Exit fullscreen mode

5️⃣ Check Configuration Errors

Run:

haproxy -c -f /etc/haproxy/haproxy.cfg
Enter fullscreen mode Exit fullscreen mode

This is the fastest way to find the issue.

6️⃣ Fix Common Issue (VERY IMPORTANT)

The most common issue is please use the 'bind' keyword for listening addresses.

7️⃣ Fix Configuration File

SSH into App Server 1

# Open new tab and SSH into stapp01
ssh tony@stapp01
# Check Apache status
systemctl status httpd
# Check Apache config for listening port
sudo grep -i listen /etc/httpd/conf/httpd.conf
Enter fullscreen mode Exit fullscreen mode
# Edit HAProxy config by using loki@stlb01
vi /etc/haproxy/haproxy.cfg
Enter fullscreen mode Exit fullscreen mode

Make sure you have:

frontend http_front
    bind *:80
    default_backend app_servers

backend app_servers
    balance roundrobin
    server app1 stapp01:8080 check
    server app2 stapp02:8080 check
    server app3 stapp03:8080 check
Enter fullscreen mode Exit fullscreen mode

8️⃣ Restart HAProxy

systemctl restart haproxy
Enter fullscreen mode Exit fullscreen mode

9️⃣ Verify Service

systemctl status haproxy
Enter fullscreen mode Exit fullscreen mode

Expected:

active (running)

🔟 Test the Application

curl http://stlb01:80/

You should see the webpage output.


🧠 Part 2: Simple Explanation (Beginner Friendly)

What this lab is testing

This lab checks your ability to:

troubleshoot services

fix configuration errors

validate load balancer behavior

Why HAProxy failed

HAProxy usually fails due to:

Issue Result
Wrong port backend unreachable
Syntax error service won't start
Missing backend no routing
Wrong hostname cannot resolve
Most common mistake in THIS lab

Using:

server app1 stapp01:80

instead of:

server app1 stapp01:6100

Remember:

App servers → 8080
Users → 80
How traffic flows
Client → stlb01:80

HAProxy

stapp01:8080
stapp02:8080
stapp03:8080
Why haproxy -c is important

This command:

haproxy -c -f /etc/haproxy/haproxy.cfg

checks config without starting service.

It tells you:

exact line of error

This is the fastest troubleshooting method.


Resources & Next Steps
📦 Full Code Repository: KodeKloud Learning Labs
📖 More Deep Dives: Whispering Cloud Insights - Read other technical articles
💬 Join Discussion: DEV Community - Share your thoughts and questions
💼 Let's Connect: LinkedIn - I'd love to connect with you

Credits
• All labs are from: KodeKloud
• I sincerely appreciate your provision of these valuable resources.

Top comments (0)