Errorfile with conditions

Hi,

We have backends that serve json and html pages. Is there a way to return HAProxy errors based on ACLs? For example if path begins with /json then return the internal errors in json otherwise return in html.
What we tried:

  • http-response return status 500 errorfiles json if { status eq 500 } masks backend errors and is not what we want.
  • errorfile or http-error directives would work but because the same backend can return json or HTML we need to specify conditions but it doesn’t seem to support ACLs.
  • duplicating backends and use different errorfiles is not a usable solution because we have many backends and complex ACLs to know when to return json and when to return HTML.

Looking for something similar to: errorfiles json if { path -i -m beg /json }

With nginx we can do that with error_page 500 502 503 /$status.$format;

Thanks!

No, it isn’t (you have already listed the workarounds above).

You can file feature requests on Github:

Thanks Lukas.