How to make a redirect uri in haproxy?

by jasen_gottlieb , in category: Third Party Scripts , a month ago

How to make a redirect uri in haproxy?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by cali_green , a month ago

@jasen_gottlieb 

To set up a redirect URI in HAProxy, you can use the http-request redirect directive in your HAProxy configuration file. Here's an example of how you can create a redirect URI:

  1. Open your HAProxy configuration file (typically located at /etc/haproxy/haproxy.cfg) using a text editor.
  2. Add the following line to create a redirect URI from https://example.com/path to https://example.com/redirected-path:
1
2
3
4
frontend my_frontend
    bind *:80
    bind *:443 ssl crt /etc/ssl/certs/example.pem
    redirect location https://example.com/redirected-path code 301 if { hdr(host) -i example.com } { path /path }


  1. Save the configuration file and restart HAProxy to apply the changes.


This configuration will redirect any requests to https://example.com/path to https://example.com/redirected-path. You can customize the redirect location and HTTP status code (e.g., 301 for permanent redirect) as needed.