Hello. Newish to HAProxy and having some difficulty. I have a backend and want the destination ip and backend name added to a map file if the status code is 404. Backend configuration is very simple:
backend MyBackend
server my_server 127.0.0.1:5555
http-response set-map(/path/to/my.map) %[dst] MyBackend if { status 404 }
I’ve verified that the map is recognized by HAProxy via the runtime api:
echo “show map” | socat stdio /path/to/haproxy.sock
The map shows up in the output.
However, I am trying to read it at runtime with the Golang client-native runtime client. I have a goroutine set to check it every n seconds. But I always get an error re: “cannot parse json”, essentially saying it’s empty.
The file does start empty, but I am hoping to add to it via the above.
Any ideas as to where I am going wrong would be appreciated.
For what it’s worth, if I change the http-response line to:
http-response set-header x-not-found true if { status 404 }
It does add the header on the response. Thanks for reading.