系统相关
首页 > 系统相关> > “SSL证书错误”的自定义nginx错误页面

“SSL证书错误”的自定义nginx错误页面

作者:互联网

如果客户将选择过期的证书,则nginx服务器将显示内置错误页面.

<html>
<head><title>400 The SSL certificate error</title></head>
<body bgcolor="white">
<center><h1>400 Bad Request</h1></center>
<center>The SSL certificate error</center>
<hr><center>nginx</center>
</body>
</html>

如何捕获错误并向客户端显示不同的页面?

解决方法:

请参考http://nginx.org/en/docs/http/ngx_http_ssl_module.html#errors

为代码400定义错误页面将不起作用.工作方法是

server {
    ...
    error_page 495 496 497 https://www.google.com;
    ...
}

因此,未能提交有效证书的用户将重定向到google.com.当ssl_verify_client设置为on或optional时,这将起作用.

另一种方法仅在$ssl_verify_client设置为可选时才有效,您可以使用$ssl_client_verify进行重定向.

if ($ssl_client_verify = NONE) { 
    return 303 https://www.google.com;
}

当$ssl_verify_client设置为on时,它将无法工作.

标签:nginx,ssl,ssl-certificate,client-certificates
来源: https://codeday.me/bug/20190516/1116602.html