Quantcast
Channel: HAProxy community - Latest topics
Viewing all articles
Browse latest Browse all 4731

Dynamic server name and header

$
0
0

@jbrahy wrote:

I’m looking for the equivalent of this code block below for requests to www.example.com and example.com. Can I do string concatenation like this?

http-response set-header X-Target  example.com
server web-servers  site.example.com:80 check

This is what I want to try. I just want to know if I’m crazy.

http-response set-header X-Target  %[req.hdr(Host)]
server web-servers  site.%[req.hdr(Host),regsub(^www.,,)]:80 check

HA-Proxy version 1.8.12-8a200c7 2018/06/27

I’m getting this error when I try haproxy -c -f haproxy.test

[root@pm-prod-haproxy05 haproxy]# haproxy -c -f haproxy.test
[ALERT] 259/180932 (16116) : parsing [haproxy.test:40]: ‘http-response set-header’: sample fetch <req.hdr(Host)> may not be reliably used here because it needs ‘HTTP request headers’ which is not available here.
[ALERT] 259/180932 (16116) : Error(s) found in configuration file : haproxy.test
[root@pm-prod-haproxy05 haproxy]#

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4731

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>