For the complete documentation index, see llms.txt. This page is also available as Markdown.

HAProxy Configuration Guide

This guide walks you through setting up an HAProxy reverse proxy on Ubuntu 22.04 with:

  • A path-based reverse proxy where yourwebiste.com/hash points to hash.yourwebsite.com

  • HTTPS support using Let’s Encrypt via Certbot and a standalone method


Prerequisites

  • A server running Ubuntu 22.04

  • A registered domain name (e.g., yourwebsite.com)

  • DNS A record pointing yourwebsite.com to your server’s IP


Step 1: Install HAProxy

sudo apt update
sudo apt install haproxy -y

Enable and start the HAProxy service:

sudo systemctl enable haproxy
sudo systemctl start haproxy

Step 2: Install Certbot (Let’s Encrypt Client)


Step 3: Generate SSL Certificate with Certbot (Standalone)

Temporarily stop HAProxy to allow Certbot to bind to port 80:

Run Certbot with the standalone plugin:

After success, your certificate will be in:

Restart HAProxy:


Step 4: Configure HAProxy

Edit the HAProxy config file:

Example configuration:

Check the config:

Reload HAProxy:


Step 5: Verify Setup

Visit:

It should forward the request to:


Step 6: Auto-Renew Certificates

Edit the crontab:

Add the following to renew and reload HAProxy every 12 hours:


Conclusion

You now have:

  • HAProxy running on Ubuntu 22.04

  • HTTPS via Let’s Encrypt

  • Reverse proxy from site.com/x to x.site.com


If you have any questions or feedback, please open a request on our Helpdesk.

Last updated

Was this helpful?