httprequesthaproxyapi-gateway

HAProxy http-request with DATAPLANE API


I am fiddling around with dataplaneapi which is a great addition. However, I cant find proper parameters for manipulating a http-request in my frontend. The rule needs to look like this:

http-request replace-header Host .* 1595708099.pages.domain.de if ACL_somename_de

My current request goes to http_request_rules endpoint: /services/haproxy/configuration/http_request_rules The request body looks like this:

{ "cond": "if", "cond_test": "ACL_somename_de", "hdr_name": "Host", "index": 0, "type": "replace-header" }

The output is:

http-request replace-header Host if ACL_somename_de

However I am still missing the regex condition part. On the regular HAproxy docs its called and See: https://www.haproxy.com/documentation/aloha/12-5/traffic-management/lb-layer7/http-rewrite/

I cant find these values in the dataplane documentation. https://www.haproxy.com/documentation/dataplaneapi/latest/#operation/createHTTPRequestRule

Is this even possible and if yes how?


Solution

  • I asked the folks over at github and they delivered the answer:

    curl --request POST \
      --url 'http://127.0.0.1:5679/v2/services/haproxy/configuration/http_request_rules?parent_name=test_2&parent_type=frontend&version=61' \
      --header 'Authorization: Basic YWRtaW46YWRtaW4=' \
      --header 'Content-Type: application/json' \
      --data '{
      "cond": "if",
      "cond_test": "ACL_somename_de",
      "index": 0,
      "type": "replace-header",
      "hdr_format": "1595708099.pages.domain.de",
      "hdr_match": ".*",
      "hdr_name": "Host"
    }'
    

    Source: dataplaneapi github issues.