HAProxy community

Redirect with client IP in url

hi community, i have a somewhat weird question, but we need this for a workaround:

  • I want to call: http://my-haproxy-instance
  • it should answer with: HTTP 301 -> http://final-url/?client_ip=IP_OF_THE CLIENT (with IP_OF… being replaced by the caller’s ip of course)

is that possible? if yes, could someone provide a snippet? please dont ask why, it’s a workaround for an internal app’s limitation.

Hi,

you can use the http-request redirect action for this.

http-request redirect location http://final-url/?client_ip=%[src] code 301 if/unless

thanks a lot, I’ll tive this a try and see if it works :slight_smile: