I have a requirement to use backend servers in remote countries if the user’s home country preference is set to that country.
Right now when a user logs in, I query a haproxy map for their login id and return the two letter country code.
Then their authentication request is directed to that remote region, or local depending on the country code.
This is working.
But I need to come up with some logic for syncing the haproxy map with a global source of truth redis table.
I know I can use socat to add / remove entries to the haproxy map.
But I would like to implement something in haproxy that queries the haproxy map, and if the login id is not found it considers it a cache miss and goes to lua to query the global source of truth redis table, if the user is found there lua then updates the local haproxy map and also updates the proper variable with the country code to pass the users authentication request to the proper country.
Has anyone done anything like this? I am looking for lua examples of how to first connect to Redis, and make queries, then update the local haproxy map.