1

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!

HopelessN00b
  • 53,795
  • 33
  • 135
  • 209
EdenCloud
  • 41
  • 1
  • 4
  • 1
    have you seen the following thread: http://serverfault.com/questions/693753/using-haproxy-environmental-variables-in-haproxy-cfg-not-working – SYN Nov 12 '16 at 17:28
  • 1
    Could you confirm which GNU/Linux distribution you are using? If, for example, the distribution uses `systemd` as its init system, `haproxy` will no be able to get environment variables from `bash`. – Anderson Medeiros Gomes Oct 22 '17 at 01:17

2 Answers2

1

Did you maybe try to use something like:

server  HALB_ucd1 "${UCD1_END_POINT_IP}:${UCD1_END_POINT_PORT}" check port 8444
Jakov Sosic
  • 5,267
  • 4
  • 24
  • 35
  • 2
    Unfortunately the quotes raise an error 'server HALB_ucd1' : invalid address: '"' in '"$UCD1_END_POINT_IP:8444"' Without quotes there is no error but the environment variable is not resolved. – EdenCloud Feb 16 '15 at 17:23
0

Try using: env(variablename).

However, this option seems to only exist in 1.5+.

http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#7.3.2-env

womble
  • 96,255
  • 29
  • 175
  • 230