Detailed Description of the Problem
The Lua script from an action inside a tcp-request content rule runs twice for a single request under some circumstances.
Expected Behavior
The script should run exactly once for a single request.
Steps to Reproduce the Behavior
- Use the configuration file and Lua script below to setup a TCP mode proxy
- Make two HTTP requests (within a single TCP request because of keep-alive) against the server with
curl -v http://127.0.0.1:8080/1 http://127.0.0.1:8080/2
Only the first HTTP request should be processed by the Lua script (which returns HTTP 204). The second HTTP request should go to the upstream server on port 80.
However, the Lua script runs twice on the first try. It processed both HTTP requests. Presumably because do-resolve takes time. On the second try when the DNS record is cached, or if the do-resolve action is removed, the script runs only once.
Do you have any idea what may have caused this?
Commit 9f1e9ee
If the commit above is reverted, the issue goes away.
Do you have an idea how to solve the issue?
No response
What is your configuration?
global
lua-load app.lua
listen proxy
bind :8080
tcp-request inspect-delay 5s
tcp-request content lua.app
tcp-request content do-resolve(txn.ip,default) str('haproxy.org')
server upstream 127.0.0.1:80
function app(txn)
core.Debug('lua func')
repeat
line = txn.req:getline()
core.Debug(line)
until #line <= 2 -- crlf
txn.res:send('HTTP/1.1 204 No Content\r\n\r\n')
end
core.register_action("app", {"tcp-req"}, app, 0)
Output of haproxy -vv
Linux archlinux 6.18.48-1-lts #1 SMP PREEMPT_DYNAMIC Fri, 28 Aug 2026 11:47:30 +0000 x86_64 GNU/Linux
HAProxy version 3.4.4 2026/08/27 - https://haproxy.org/
Status: long-term supported branch - will stop receiving fixes around Q2 2031.
Known bugs: http://www.haproxy.org/bugs/bugs-3.4.4.html
Running on: Linux 6.18.48-1-lts #1 SMP PREEMPT_DYNAMIC Fri, 28 Aug 2026 11:47:30 +0000 x86_64
Build options :
TARGET = linux-glibc
CC = cc
CFLAGS = -O2 -g -fwrapv -fvect-cost-model=very-cheap -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=
3 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-
prefix-map=/build/haproxy/src=/usr/src/debug/haproxy -flto=auto -fwrapv
OPTIONS = USE_GETADDRINFO=1 USE_OPENSSL=1 USE_LUA=1 USE_ZLIB=1 USE_QUIC=1 USE_PROMEX=1 USE_PCRE2=1 USE_PCRE2_JIT=1
DEBUG =
Detailed Description of the Problem
The Lua script from an action inside a
tcp-request contentrule runs twice for a single request under some circumstances.Expected Behavior
The script should run exactly once for a single request.
Steps to Reproduce the Behavior
curl -v http://127.0.0.1:8080/1 http://127.0.0.1:8080/2Only the first HTTP request should be processed by the Lua script (which returns HTTP 204). The second HTTP request should go to the upstream server on port 80.
However, the Lua script runs twice on the first try. It processed both HTTP requests. Presumably because
do-resolvetakes time. On the second try when the DNS record is cached, or if thedo-resolveaction is removed, the script runs only once.Do you have any idea what may have caused this?
Commit 9f1e9ee
If the commit above is reverted, the issue goes away.
Do you have an idea how to solve the issue?
No response
What is your configuration?
Output of
haproxy -vv