# Why lua script on the http-response triggered twice?

**URL:** <https://discourse.haproxy.org/t/why-lua-script-on-the-http-response-triggered-twice/7667>\
**Category:** Help!\
**Created:** [May 19, 2022, 8:31am UTC](https://discourse.haproxy.org/t/why-lua-script-on-the-http-response-triggered-twice/7667 "2022-05-19T08:31:46Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![iye](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@iye](https://discourse.haproxy.org/u/iye)\
**Post date:** [May 19, 2022, 8:31am UTC](https://discourse.haproxy.org/t/why-lua-script-on-the-http-response-triggered-twice/7667/1 "2022-05-19T08:31:46Z")

</div>

Greetings!  
For some reason I see double output of a lua func in the haproxy log. Imo, this mean the func triggered twice. Is it a normal behaviour ? Is it possible to avoid double func call ?  
Haproxy version - 2.4  
Configuration:  
[haproxy.cfg]  
global  
log /dev/log local0 debug  
chroot /var/lib/haproxy  
stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners  
stats timeout 30s  
user haproxy  
group haproxy  
daemon  
ca-base /etc/ssl/certs  
crt-base /etc/ssl/private

ssl-default-bind-ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:E  
CDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384  
ssl-default-bind-ciphersuites TLS\_AES\_128\_GCM\_SHA256:TLS\_AES\_256\_GCM\_SHA384:TLS\_CHACHA20\_POLY1305\_SHA256  
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets  
lua-load /etc/haproxy/lua/register.lua  
defaults  
log global  
mode http  
option httplog  
option dontlognull  
option log-health-checks  
timeout connect 5000  
timeout client 50000  
timeout server 50000

frontend stats  
bind :11404  
stats enable  
stats uri /  
stats refresh 10s

frontend a\_cluster  
bind \*:10080  
filter spoe engine request-cache config /etc/haproxy/request-cache.conf  
http-request wait-for-body time 1s at-least 10k  
http-request lua.pre\_node\_rp\_route rp\_cluster\_nodes  
http-response lua.post\_rp\_route rp\_cluster\_nodes  
default\_backend rp\_cluster\_nodes  
option forwardfor header X-Real-IP

backend rp\_cluster\_nodes  
option httpchk  
http-check send meth GET uri /actuator/rphealth  
http-check expect string “{“status”:“UP”}”  
balance hdr(“X-Selected-Node”)  
server node\_01 10.20.0.79:8080 ssl verify none check port 8081 check-ssl verify none inter 5000  
server node\_02 10.20.0.46:8080 ssl verify none check port 8081 check-ssl verify none inter 5000  
server node\_03 10.20.0.48:8080 ssl verify none check port 8081 check-ssl verify none inter 5000

backend agent  
mode tcp  
balance roundrobin  
timeout connect 5s # greater than hello timeout  
timeout server 3m # greater than idle timeout  
option spop-check  
server iye 10.10.0.10:9000 check

[register.lua]  
…  
local function post\_rp\_route(txn, cluster\_name)  
core.Info(“Headers :” … txn:get\_var(“txn.request\_cacher.hdrs”))  
end

core.register\_action(“post\_rp\_route”, {‘http-res’}, post\_rp\_route, 1)

[haproxy.log]

May 19 07:53:47 testnginxrp haproxy[120999]: Headers :.x-terminal-id.1234567890.authorization.Basic XXXXXXXXXX=.content-type.application/json.user-agent.PostmanRuntime/7.29.0.accept._/_.cache-control.no-cache.postman-token$e64c3f99-b923-4397-b473-768ddf714973.host.10.20.0.49:10080.accept-encoding.gzip, deflate, br.content-length.1373  
May 19 07:53:47 testnginxrp haproxy[120999]: 10.10.0.10:59850 [19/May/2022:07:53:46.986] rp\_cluster rp\_cluster\_nodes/node\_02 4/0/64/51/119 403 440 - - ---- 1/1/0/0/0 0/0 “POST /api/v1/transfer HTTP/1.1”  
May 19 07:53:47 testnginxrp haproxy[120999]: [info] 138/075347 (120999) : Headers :.x-terminal-id.1234567890.authorization.Basic XXXXXXXXXX=.content-type.application/json.user-agent.PostmanRuntime/7.29.0.accept._/_.cache-control.no-cache.postman-token$e64c3f99-b923-4397-b473-768ddf714973.host.10.20.0.49:10080.accept-encoding.gzip, deflate, br.content-length.1373

---

<div class="post-metadata">

**Author:** ![iye](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@iye](https://discourse.haproxy.org/u/iye)\
**Post date:** [May 19, 2022, 12:29pm UTC](https://discourse.haproxy.org/t/why-lua-script-on-the-http-response-triggered-twice/7667/2 "2022-05-19T12:29:07Z")

</div>

It is not doubled call. It is some logging specific.
