Skip to content

Instantly share code, notes, and snippets.

View calexandre's full-sized avatar
:shipit:
🤘

Carlos Alexandre calexandre

:shipit:
🤘
View GitHub Profile
@kamleshchandnani
kamleshchandnani / haproxy-reqrep.md
Last active April 25, 2023 15:50
Understanding "reqrep" in HA Proxy config

Let's assume we have following line in our HA proxy file:
reqrep ^([^\ :]*)\ /api/v1/api-name/(.*) \1\ /staging/path-name/\2
Here is our sample domain:
https://example.com/api/v1/api-name/

The goal here is to rewrite /api/v1/api-name/ to /staging/path-name/ leaving anything else unchanged.

Breaking the Regex and understanding in parts:
There are basically 3 parts in the regex: