Hello all, I hope you are doing well. If someone has an idea on it, please don’t hesitate
Thanks a lot and have a great day!
Our context
We are connecting to an external API via https to detect bot activity with lua (https://www.arpalert.org/src/haproxy-lua-api/2.6/index.html)
- The code is executed on the frontend (hook), before calling the backend.
- If we reach the timeout (detected by httpclient:post), we just let the request go through and we call the backend
- If bot activity is detected: we respond with a 403
Everything works as expected when the endpoint is available.
Our problem
However, if we have a wrong IP, unresolvable name or unavailability/network problem, the timeout of the function httpclient:post does not work. (we wait a long time before seeing the backend results)
The documentation says that this is the “timeout server”, so we tried a lot of configuration without success, for example:
- We changed the ‘timeout client’ (and the other values), however this stops the whole frontend execution and does not call the backend (undesirable behavior).
- We tried ‘tune.lua.*’ variables, but it did not change anything.
Question
- Maybe we are doing something wrong?
- Maybe the lua api does not support this?
Code / Configuration
haproxy.cfg (frontend part)
frontend http-in
...
http-request lua.my_request_hook
http-response lua.my_response_hook
...
use_backend failure_backend if { var(txn.my.status) -m str "blocked" }
default_backend webservers
lua code
local CONFIG = { ... }
local res = httpclient:post {
url = CONFIG.api_url,
headers = myHeaders,
body = helpers.stringify(myBody),
timeout = CONFIG.timeout,
}