Bash – How to use environment variable in haproxy

bashhaproxyload balancing

I work with haproxy 1.5.2
My haproxy.cfg has this server definitions:

server  HALB_ucd1 ${UCD1_END_POINT_IP}:${UCD1_END_POINT_PORT} check port 8444

I set the UCD1_END_POINT_IP and UCD1_END_POINT_PORT in the bash and
start haproxy with service haproxy restart

The haproxy restarted OK but the UCD1_END_POINT_IP and UCD1_END_POINT_PORT are not resolved.
I see that as per haproxy doc it is supported:

    Any part of the address string may reference any number of environment 
   variables by preceding their name with a dollar sign ('$') and optionally 
   enclosing them with braces ('{}'),
   similarly to what is done in Bourne shell.

If I change it for hard coded ip and port it works fine.
What do I miss?

Thank you!

Best Answer

Did you maybe try to use something like:

server  HALB_ucd1 "${UCD1_END_POINT_IP}:${UCD1_END_POINT_PORT}" check port 8444