0

I want to serve a static file like errorfile when the response status is 500. I have to use this config in the backend section.

1 Answers1

2

I've checked the HAProxy documentation but could not immediately find a configuration setting for this. But why do you want HAProxy to catch this error and return a custom HTML page? Your backend web server allows having custom error pages for code 404 and 500.

Edit: So I checked the documentation a bit more and although I haven't tested it (yet), we can perhaps try the following code in the frontend/listen/backend statement:

acl error_codes -m beg "HTTP/1.0 500"
acl error_codes -m beg "HTTP/1.0 404"
http-response allow redirect location http://example.com/errors/404.html if error_codes
Tommiie
  • 5,627
  • 2
  • 12
  • 46