How to show an empty error page on HAProxy for a single URL

503-errorhaproxy

Question

I have a single URL say:

http://foo-backend.com/display_blank_when_errored

On a site behind an HAProxy load balancer let's say the front-end site is:

http://foo.com

When an error happens 99% of the time I want to show the error pages configured with errorfile but only on this single page I want it to return a blank response. How would I go about doing this?

Background

This is using HAProxy 1.5.

I have a page that is being used around the internet in an IFrame and in the rare case that the server is down, rather than displaying an error page, I want it to display nothing so that the user experience is not affected.

Best Answer

You may use different backend section for specified URL. For example:

frontend webserver
   use_backend srv_noerrors if { url_beg /display_blank_when_errored }
   default_backend srv_werrors

backend srv_noerrors
   errorfile 503 /etc/haproxy/errors/503err_blank.http

backend srv_werrors
   errorfile 503 /etc/haproxy/errors/503err_info.http