HAProxy community

Redirect request transparently and change path

I need to redirect a web request as follows, and can’t get it working with HAProxy.
Original URL:
http://mywebpage.com/webservices/index.asp?param1?parm2

Redirect transparently (so client doesn’t see URL change) to:
https://myazuresite.azurewebsites.net/FunctionName?code=AzureFunctionID&url=/webservices/index.asp?param1?parm2

I can get it working with:
http-request redirect prefix https://myazuresite.azurewebsites.net/FunctionName?code=AzureFunctionID&url=

But this changes the URL presented to the user to that address, which will break application code.

Does anyone know how to do this?

It’s a terminology issue:

A redirect means that the server will tell the browser to go to another URL, which the client will see.

Changing to URI to to be send to the backend server is called rewriting.

Use http-request replace-uri:

https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4.2-http-request%20replace-uri

1 Like

thanks for your answer lukas. i was wondering the exact same thing a while back and never got an answer. now i may try to do it again. can i ask you questions in case there’s something to ask? thanks

Sure, but please don’t ask if you can ask. Just ask.