Support multiple backends per domain with the help of some lua

This commit is contained in:
Thomas Lynch
2023-04-06 22:40:03 +10:00
parent 35668c9b58
commit 40da57544a
4 changed files with 34 additions and 7 deletions

View File

@@ -7,3 +7,16 @@ core.register_action("captcha-check", { 'http-req', }, bot_check.check_captcha_s
core.register_action("pow-check", { 'http-req', }, bot_check.check_pow_status)
core.register_action("decide-checks-necessary", { 'http-req', }, bot_check.decide_checks_necessary)
core.register_action("kill-tor-circuit", { 'http-req', }, bot_check.kill_tor_circuit)
local backends_map = Map.new('/etc/haproxy/map/backends.map', Map._str)
function get_server_names(txn)
local key = txn.sf:hdr("Host")
local value = backends_map:lookup(key or "")
if value ~= nil then
return value
else
return ""
end
end
core.register_fetches("get_server_names", get_server_names)