David Moreno García
David Moreno García

Reputation: 4523

Get HAProxy server name on response

I'm trying to get the HAProxy backend name for every response. For this I have a lua action like the following one:

core.register_action("hook", { "http-res" }, function(txn)
  txn:Info()
end)

and this config in the haproxy:

...
backend backend-puppetserver
  balance roundrobin
  http-response lua.hook
  server server_1 192.168.1.3
...

My problem is that no matter what I try to print that info (txn.sf, headers, etc.) I'm totally unable to find the server name (server_1) or it's ip. Where is that data stored? I can't find anything in the documentation. The most I get is the id by using txn.sf:srv_id()

Just to add that yeah, the action is working and it's printing information. This is just a matter of find the right call to fetch the server name.

Upvotes: 1

Views: 952

Answers (1)

nuster cache server
nuster cache server

Reputation: 1791

You can use

http-response set-header BackendServer %s

Upvotes: 2

Related Questions