HAProxy community

Header driven server address


Hello I’m attempting to route traffic back to a requester’s machine in order to run a site locally but at the same time picking up the headers/cookies/routing logic for serving content for other origins that HAProxy takes care of. Thus far though I have not been able to figure out how to do this. Below is roughly what I’m trying to accomplish. but you cannot pass the header value in at that time. I’ve done a proof of concept putting my IP instead of hdr(originalIp) and it works. One person suggested a dev machine mapping and using a different backend depending on a request value but we have dynamic IPs.

### Sample config
acl has_local_cookie cook_sub(local) -i true
use_backend local    if has_local_cookie

backend local
server local-origin hdr(originalIp):443 ssl verify none


If you use dynamic IPs, you should give a try to DNS then.
Update the A record (or create a CNAME which points to the A of your server) each time your origin changes.