Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom nginx error page for "The SSL certificate error"

If the customer will choose the expired certificate, the nginx server will show the built-in error page.

<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>

How can I catch the error and show the client a different page?

like image 444
user3138912 Avatar asked Nov 06 '15 05:11

user3138912


2 Answers

Please refer to http://nginx.org/en/docs/http/ngx_http_ssl_module.html#errors

Define an error page for code 400 will not work. The working approach is

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

So a user failed to submit a valid certificate will be redirect to google.com. This will work when ssl_verify_client is set to on or optional.


Another approach works only when $ssl_verify_client is set to optional, you could use $ssl_client_verify for redirecting.

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

When $ssl_verify_client is set to on, it will not work.

like image 140
dommyet Avatar answered Oct 21 '22 10:10

dommyet


There is a way you can show the client a diffrent page. The way you do this is basically the same as stated above but instead you change the google website to a page that you created:

server {
    ...
    error_page 495 496 497 /error400.html;
    ...
}

Just be sure to include all you're custom pages in each server instance.

like image 29
permission_denied Avatar answered Oct 21 '22 11:10

permission_denied