errorfile
Return a file contents instead of errors generated by HAProxy
May be used in sections :
defaults frontend listen backend
yes
yes yes
yes yes
yes yes
yes
Arguments :
is the HTTP status code. Currently, HAProxy is capable of
generating codes 200, 400, 403, 405, 408, 429, 500, 502, 503, and
504.
Code 200 is emitted in response to requests matching a "monitor-uri" rule.
The files are returned verbatim on the TCP socket. This allows any trick such as redirections to another URL or site, as well as tricks to clean cookies, force enable or disable caching, etc... The package provides default error files returning the same contents as default errors.
The files should not exceed the configured buffer size (BUFSIZE), which generally is 8 or 16 kB, otherwise they will be truncated. It is also wise not to put any reference to local contents (eg: images) in order to avoid loops between the client and HAProxy when all servers are down, causing an error to be returned instead of an image. For better HTTP compliance, it is recommended that all header lines end with CR-LF and not LF alone.
The files are read at the same time as the configuration and kept in memory. For this reason, the errors continue to be returned even when the process is chrooted, and no file change is considered while the process is running. A simple method for developing those files consists in associating them to the 403 status code and interrogating a blocked URL. See also : "errorloc", "errorloc302", "errorloc303" Example : errorfile 400 /etc/haproxy/errorfiles/400badreq.http errorfile 408 /dev/null # work around Chrome pre-connect bug errorfile 403 /etc/haproxy/errorfiles/403forbid.http errorfile 503 /etc/haproxy/errorfiles/503sorry.http