Score:0

haproxy regrep usage to insert to path

ru flag

I have a haproxy service running on localhost:8090 with a backend service running on localhost:8080 and I want to transform GET request such as:

curl http://127.0.0.1:8090/api/v1/pods  (received by haproxy)
to
curl http://127.0.0.1:8080/api/v1/tenants/all/pods (received by backend)

I see a "Bad Request" response from 127.0.0.1:8080 . Haproxy config:

...
frontend operator_proxy
        bind 127.0.0.1:8090
        use_backend multi_tenancy_api_server
        default_backend multi_tenancy_api_server

backend multi_tenancy_api_server
        mode http
        reqrep ^(.*)\/v1\/pods(.*) \1\/v1\/tenants\/all\/pods\3
        server ark_api 127.0.0.1:8080 maxconn 500000 

Transformed request looks ok as per tcpdump at port 8080. I've gleaned through various similar questions and haproxy manual. Please review my regrep usage, I'm missing something. TIA.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.