On Thu, Jul 27, 2017 at 11:54 PM, Mark Staudinger <[email protected]>
wrote:

> Hi Folks,
>
> I'm trying to export the server_name as a response header or variable for
> logging purposes ( %s in the log format ).
>
> Is there a way to access this string in a manner similar to one of these
> methods?  I've tried the following without success (usually with a "unknown
> fetch method %s".
>
> http-response set-var(txn.servername) %s
> or
> http-response set-var(txn.servername) %[server_name]
>

​You can use this:​

​http-response set-header X-Backend-Server-Name %s

When using http-response set-header or http-response add-header, the value
argument is a "log format expression," which understands log variables.

By contrast, http-response set-variable expects a "standard HAProxy
expression formed by a sample fetch followed by some converters," so it
doesn't have access to log variables, only fetches.  There's a srv_id layer
4 fetch that can get the server's ID, but there's not a sample fetch for
the server name.

Reply via email to