Is it possible to create an ACL to query the current date inside haproxy.conf ?
For example, I may want to limit access to a backend server depending on date and/or time. I can see date specific ACLs useful for vacation booking sites or protected services like an SSH passthrough limiting logins to specific times of the day.
The following haproxy.conf example is using a static date string as a proof of concept looking for the 15th day of the month. This date string format was taken from the haproxy local time “%Tl” log variable. Is there another function like “date()” that can be queried?
frontend tcp_director
mode tcp
option tcplog
bind 127.0.0.1:443
default_backend server-01
#
# Allow access only on the 15th of the month , %Tl string
acl date_allow str("15/May/2021:14:00:44 -0400") -m beg "15/"
use_backend server-15 if date_allow
Thanks for your time. Ideas and insights are welcome.
2 posts - 2 participants