我正在摆弄 dataplaneapi,这是一个很好的补充。 但是,我无法找到在前端操作 http 请求的正确参数。该规则需要如下所示:
http-request replace-header Host .* 1595708099.pages.domain.de if ACL_somename_de
我当前的请求转到 http_request_rules 端点:/services/haproxy/configuration/http_request_rules 请求正文如下所示:
{ "cond": "if", "cond_test": "ACL_somename_de", "hdr_name": "Host", "index": 0, "type": "replace-header" }
输出为:
http-request replace-header Host if ACL_somename_de
但是我仍然缺少正则表达式条件部分。在常规 HAproxy 文档中,它被称为 看: https://www.haproxy.com/documentation/aloha/12-5/traffic-management/lb-layer7/http-rewrite/
我在数据平面文档中找不到这些值。 https://www.haproxy.com/documentation/dataplaneapi/latest/#operation/createHTTPRequestRule
这可能吗?如果可能的话怎么办?
我在 github 上询问了人们,他们给出了答案:
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"
}'