]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: httpclient: allow address and port change for resolving
authorWilliam Lallemand <wlallemand@haproxy.org>
Tue, 3 May 2022 12:09:06 +0000 (14:09 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Wed, 4 May 2022 09:21:01 +0000 (11:21 +0200)
To allow the http-request set-dst to work for the httpclient DNS
resolving, some changes need to be done:

- The destination address need to be set in the frontend (s->csf->dst)
  instead of the backend (s->csb->dst) to be able to use
  tcp_action_req_set_dst()

- SRV_F_MAPPORTS need to be set on the proxy in order to allow the port
  change in alloc_dst_address()

src/http_client.c

index e45653fb0510a5bd2d4d90cadf6a223a2bf15877..ff0298440f1287f80879d3f4f7752dc2e072febd 100644 (file)
@@ -596,8 +596,8 @@ struct appctx *httpclient_start(struct httpclient *hc)
        s->req.wto = hc->timeout_server;
        s->res.rto = hc->timeout_server;
 
-       s->csb->dst = addr;
-       s->csb->flags |= CS_FL_NOLINGER;
+       s->csf->dst = addr;
+       s->csf->flags |= CS_FL_NOLINGER;
        s->flags |= SF_ASSIGNED;
        s->res.flags |= CF_READ_DONTWAIT;
 
@@ -1114,6 +1114,7 @@ static int httpclient_precheck()
        httpclient_srv_raw->iweight = 0;
        httpclient_srv_raw->uweight = 0;
        httpclient_srv_raw->xprt = xprt_get(XPRT_RAW);
+       httpclient_srv_raw->flags |= SRV_F_MAPPORTS;  /* needed to apply the port change with resolving */
        httpclient_srv_raw->id = strdup("<HTTPCLIENT>");
        if (!httpclient_srv_raw->id)
                goto err;
@@ -1130,6 +1131,7 @@ static int httpclient_precheck()
        httpclient_srv_ssl->uweight = 0;
        httpclient_srv_ssl->xprt = xprt_get(XPRT_SSL);
        httpclient_srv_ssl->use_ssl = 1;
+       httpclient_srv_ssl->flags |= SRV_F_MAPPORTS;  /* needed to apply the port change with resolving */
        httpclient_srv_ssl->id = strdup("<HTTPSCLIENT>");
        if (!httpclient_srv_ssl->id)
                goto err;