Server line disappears from HAProxy config



  • I'm having a problem where occasionally I go to access a particular backend, and I get a 503 error. I go to look at the HAProxy config, and the server statement for that backend is missing:

    backend Zoneminder_ipvANY
    	mode			http
    	id			106
    	log			global
    	timeout connect		30000
    	timeout server		30000
    	retries			3
    	option			httpchk OPTIONS / 
    
    

    If I restart the service, the line reappears:

    backend Zoneminder_ipvANY
    	mode			http
    	id			106
    	log			global
    	timeout connect		30000
    	timeout server		30000
    	retries			3
    	option			httpchk OPTIONS / 
    	server			Zoneminder 192.168.1.13:443 id 107 ssl check inter 60000  verify none 
    

    I am baffled as to why this is happening.



  • @blueh2o
    Is the server defined with a dns name?



  • Yes, it is.



  • @blueh2o
    Then i suspect the php code (sometimes) fails to resolve that name to the proper IP when the config was generated. Can you check when the configuration was generated and if 'something' special was going on at that time? Perhaps the dns server used wasn't reachable? Or it was during a reboot while not all services were running yet?

    When the name cannot be resolved the server is skipped as otherwise haproxy would fail to start. Can you perhaps configure the dns-resolver settings of haproxy itself on the settings tab? That should get the server-name instead of the IP in the configuration and allow haproxy to resolve the name by itself at runtime.

    Might also need to add this in the advanced global textbox setting:

    defaults
        # never fail on address resolution
        default-server init-addr last,libc,none
    

    That way it should avoid the situation above. It would still return the 503 while dns doesn't work, but when dns starts working haproxy would resolved it by itself.



  • Thank you for these suggestions. I'll try them.


Log in to reply