I try to define an ACL condition in HAProxy to check for the current server time and base on the specific time I will route traffic to certain backend servers.

But I don't find in HAProxy documentation on reading or extracting current date and time.

My goal is something like this in the frontend definition:

acl check_time_is_ls_12 "logic: check current timehour < 12 "
use_backend   back_server1 if check_time_is_lt_12
use_backend   back_server2 unless check_time_is_lt_12

I believe what you are after can be done using the haproxy runtime API, described here: https://www.haproxy.com/blog/dynamic-configuration-haproxy-runtime-api/ and by cron jobs.

I am not aware of a simpler solution. Does that work for you?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.