On Mar 10, 2017 4:16 AM, "Ульянка Да" <[email protected]> wrote:

Update:
reqrep changes requests, but harmfully, that results in error 400 (bad
request).
How to debug the harm keeping in mind that traffic is SSLed?


SSL isn't really relevant, because your incorrect rewrite is corrupting the
request *inside* HAProxy.  The request never leaves the proxy.  What you
need to remember is that you are rewriting a line in a buffer that contains
a raw HTTP request.

reqrep ^([^\ :]*)\ /ABC/collection/(.*)/  \1\ /collection/collection_\2/

You're overlooking the "[space]HTTP/1.x" at the end of the start line.

reqrep ^([^\ :]*)\ /ABC/collection/(.*)/(\ HTTP.+)$ \1\
/collection/collection_\2/\3

Note that your expression as written also only works at all when the path
ends with a trailing slash, which may or may not be what you really want.
That behavior is preserved in my example.

If you're using HAProxy 1.6 or later, there is a simpler solution to use,
which looks something like this:

http-request set-path
%[path,regsub(^/ABC/collection/,/collection/collection/)] if { path_beg
/ABC/collection/ }

This also differs from your example, since it does not require a trailing
slash in the path but would match and rewrite any path beginning with the
pattern shown.

Reply via email to