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/hashpoints tohash.yourwebsite.comHTTPS 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.comto your server’s IP
Step 1: Install HAProxy
sudo apt update
sudo apt install haproxy -yEnable and start the HAProxy service:
sudo systemctl enable haproxy
sudo systemctl start haproxyStep 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/xtox.site.com
After enabling Cookie lifetime extender, the DCP will give a proxy code that is expected to be setup on https://domain.*/hash however, if it is set up on https://www.domain.*/hash it will cause a CORS Error on the Cookie Lifetime Extender Requests.
If you have any questions or feedback, please open a request on our Helpdesk.
Last updated
Was this helpful?