Skip to main content

Raymii.org Raymii.org Logo

Quis custodiet ipsos custodes?
Home | About | All pages | Cluster Status | RSS Feed

haproxy: redirect to ssl or other website

Published: 09-12-2013 | Author: Remy van Elst | Text only version of this article


❗ This post is over eleven years old. It may no longer be up to date. Opinions may have changed.

This snippet shows you how to use haproxy to redirect http traffic to https or any other website.

This snippet was tested on haproxy 1.5.

Recently I removed all Google Ads from this site due to their invasive tracking, as well as Google Analytics. Please, if you found this content useful, consider a small donation using any of the options below. It means the world to me if you show your appreciation and you'll help pay the server costs:

GitHub Sponsorship

PCBWay referral link (You get $5, I get $20 after you've placed an order)

Digital Ocea referral link ($200 credit for 60 days. Spend $25 after your credit expires and I'll get $25!)

To redirect traffic from a haproxy frontend, use the following config:

frontend example-frontend
  bind 10.20.30.40:80
  redirect location https://example.org:443

As you can see, the redirect location can be anything, for example, the ssl version of the frontend or any other website.

More info: http://cbonte.github.io/haproxy- dconv/configuration-1.5.html#redirect

Tags: apache , haproxy , loadbalancer , redirect , snippets , ssl