- haproxy 自定义错误页面有两种方式
1.一种是由haproxy本机提供错误页面,通过errorfile参数来设定。
2.第二种是将错误转到一个指定的url地址 通过 errorcode
参数来设定
errorfile来定义
errorfile\erroloc 来实现自定义错误页面:
defaults
errorfile /opt/503.http
# errorloc 503 https://www.xuliangwei.com/error/
文件内容:
[root@proxy01 ~]# cat /opt/503.http
HTTP/1.1 503
Content-Type:text/html;charset=utf-8
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>报错页面</title>
</head>
<body>
<center><h1>网站维护中..请稍候再试</h1></center>
<center><h2>请联系网站管理人员</h2></center>
<center><h3>503 Service Unavailable</h3></center>
</body>
</html>
errorloc
- 使用errorloc选项来捕捉错误状态码,然后将其重定向到其他url 修改haproxy配置
defaults
errorloc 503 https://www.yangyijing.cn/error