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

Use variables to define http-check parameters

$
0
0

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.

  1. Can such approach works or there is another way to do it?
  2. Maybe there is a way to define independent http-check blocks and then just attach them per backend?

Thank you!

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 4717

Trending Articles



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