对指定的报错进行重定向,进行优雅的显示错误页面
使用errorfile和errorloc指令的两种方法,可以实现自定义各种错误页面
基于自定义的错误页面文件
配置过程
一定要将文件写入default这个块里面
[root@haproxy ~]# vim /etc/haproxy/errorpage/503page.http
HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Connection: close
Content-Type: text/html;charset=UTF-8<html><body><h1>什么动物生气最安静</h1>
大猩猩!!
</body></html[root@haproxy ~]# vim /etc/haproxy/haproxy.cfg
errorfile 503 /etc/haproxy/errorpage/503page.http
测试结果
基于http重定向错误页面
配置过程
errorloc 503 https://www.baidu.com