Hello,
I just started to use HAProxy and trying to understand how to write config in more optimised way.
For example, we have 3 similar backends and they have some similar health checks:
http-check send meth POST uri / hdr Content-Type application/json body “{"jsonrpc":"2.0","method":"eth_syncing","params":,"id":1}”
It works fine when it is placed in such a way for every backend. As it is repeated more than one time, I’m trying to put it in the global
section in a variable and then use just a variable in http-check.
global
set-var-fmt proc.eth_sync "{\"jsonrpc\":\"2.0\",\"method\":\"eth_syncing\","params\":[],\"id\":1}"
# set-var-fmt proc.eth_sync "{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}"
backend oe
option httpchk
http-check send meth POST uri / hdr Content-Type application/json body "%[var(proc.eth_sync)]"
# http-check send meth POST uri / hdr Content-Type application/json body "%[var(proc.eth_sync),json]"
I also tried to use environment variables but got similar result - it doesn’t work.
- Can such approach works or there is another way to do it?
- Maybe there is a way to define independent http-check blocks and then just attach them per backend?
Thank you!