Mask sensitive data in logs

No easy way as far as I can see, a feature request for a simpler solution has been posted here:

Here’s a LUA workaround:

/etc/haproxy/anonymizeToken.lua:

local function anonymizeToken(url)
   if url == nil then
       return
   end
   url = url:gsub("token=[^&]+", "token=******")
   return url
 end

core.register_converters("anonymizeToken", anonymizeToken)

Config:

global
    lua-load /etc/haproxy/anonymizeToken.lua

frontend blabla
    log-format "%[capture.req.uri,lua.anonymizeToken]"
1 Like