From: William Lallemand Date: Tue, 3 May 2022 12:09:06 +0000 (+0200) Subject: MEDIUM: httpclient: allow address and port change for resolving X-Git-Tag: v2.6-dev9~108 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1218d19921c64650b90ed06cfb5c328dc867286c;p=thirdparty%2Fhaproxy.git MEDIUM: httpclient: allow address and port change for resolving 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() --- diff --git a/src/http_client.c b/src/http_client.c index e45653fb05..ff0298440f 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -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(""); 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(""); if (!httpclient_srv_ssl->id) goto err;