如果客户选择过期的证书,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
设置为 optional
时有效,您可以使用 $ssl_client_verify
进行重定向。
if ($ssl_client_verify = NONE) {
return 303 https://www.google.com;
}
当$ssl_verify_client
设置为on
时,它将不起作用。
关于ssl - "The SSL certificate error"的自定义 nginx 错误页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33560256/