I have two incoming requests, one of it needs to go to a “http:// server” and other to “https:// server”.
Below is my acl and backend definitions
------in haproxy_peers.cfg---------
acl downstream_service1 path_beg /downstream_serv1/internal/api
acl downstream_service2 path_beg /downstream_serv2/internal/api
use_backend downstream_serv1_http if downstream_service1
use_backend downstream_serv2_https if downstream_service2
------------------------------------------
backend configs:
--------in backend config file-----------
backend downstream_serv1_http
http-request set-path "%[path,regsub(^/downstream_serv1/,/)]"
server downstream_server1 host-name.domain:port_number check //*note there is no http/https protocol mentioned.*
backend downstream_serv2_https
http-request set-path "%[path,regsub(^/downstream_serv2/,/)]"
server downstream_server2 host-name2.domain:port_number check //*note there is no http/https protocol mentioned.*
---------------------------------------------
Expectation is
http://haproxyHost/downstream_serv1/internal/api
should be routed to http://host-name.domain:port_number/internal/api
http://haproxyHost/downstream_serv2/internal/api
should be routed to https://host-name2.domain:port_number/internal/api