0

I would like to use HAProxy to route the incoming request http://example.com/test/app/v1/foo/bar to http://example.com/v1/app/foo/bar.

I went through the example at Haproxy route and rewrite based on URI path and constructed the regex:

reqrep ^([^\ ]\*)\ /([a-zA-Z]\*)/([a-zA-Z]\*)/([0-9A-Za-z]\*)/(.\*)  \1\ /\4/\3/\5

However it doesnt seem to work. Could anyone help figure this out?

Thanks.

Community
  • 1
  • 1
user320550
  • 1,093
  • 6
  • 20
  • 37

1 Answers1

0

Do not escape the asterisk characters (if you are using a recent version, you can even use quotes and not escape anything):

reqrep ^([^\ ]*)\ /([a-zA-Z]*)/([a-zA-Z]*)/([0-9A-Za-z]*)/(.*) \1\ /\4/\3/\5

Following test works

$ curl -IL http://127.0.0.1/test/app/v1/foo/bar
127.0.0.1 - - [09/Jul/2016:01:45:01 +0200] "HEAD /v1/app/foo/bar HTTP/1.1" 404 0 "-" "curl/7.47.0"
anine.io
  • 361
  • 3
  • 4