Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

small misunderstandings in your haproxy reqrep markdown #2

Open
sese opened this issue Apr 4, 2019 · 0 comments
Open

small misunderstandings in your haproxy reqrep markdown #2

sese opened this issue Apr 4, 2019 · 0 comments

Comments

@sese
Copy link

sese commented Apr 4, 2019

You assume in the bellow expression:

reqrep ^([^\ :]*)\ /api/v1/api-name/(.*) \1\ /staging/path-name/\

the first expression in search is the host, also you don't give an explanation for spaces before first and second reg expression and also there is a space at replacing path.

You consider as sample the expression:

https://example.com/api/v1/api-name/

But this is wrong because the expression is something like:

GET /api/v1/api-name/

So, the first match corresponds to a method, not to a host

You can figure this out if you read the tutorial related to reqrep, where tells:

The statement reqrep applies a regex to each line of the request buffer in a case sensitive manner. As does reqirep, which is case insensitive

So, the request buffer looks like bellow:

GET /api/v1/api-name HTTP/1.1 User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT) Host: www.tutorialspoint.com Accept-Language: en-us Accept-Encoding: gzip, deflate Connection: Keep-Alive

Now I believe make more sense why there is a space after the first reg expression

^([^\ :]*)\ /api/v1/api-name/(.*)

will match the expression

GET /api/v1/api-name HTTP/1.1

In conclusion, there are no 3 parts in regex, but only 2, as the haproxy tutorial explain:

reqrep <search> <replace> [<cond>]

Thank you for your effort, you point me to right direction, also that space bother me and I investigate more in order to understand better. So I'd like to share my effort in order to let you fix your explanation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant