0

haproxy version 1.5.18

I want to redirect:

/document/(.*)/(.*)/somefile => /anotherPath/somefile

For example: redirect

/document/20181/20182/a_good_pic.jpg => /anotherPath/a_good_pic.jpg

How to do that with haproxy?

I retried follow the example for reqirep like:

# replace "/static/" with "/" at the beginning of any request path.
reqrep ^([^\ :]*)\ /static/(.*)     \1\ /\2

But my example has two parts in URL path that are different to the example, so I got confused.

Thanks!

2
  • 1
    This is much easier in HAProxy 1.6 and later, where you have access to features like http-request set-path and a converter called regsub. Also you are using the word redirect but you don't appear to actually want a redirect -- sending the browser the browser to a new URL with an HTTP 30X response. Do you want a redirect? Or do you want to rewrite the request before sending it to the back-end? Jan 26 '19 at 4:03
  • Thanks. I will try HAProxy 1.6, if the IT people could upgrade it. Actually we don't care if it is a redirect or rewrite, as long as the last URL works for the user to download the required files.
    – r ne
    Jan 27 '19 at 8:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.