Return custom 403 error page with nginx

前端 未结 4 2057
星月不相逢
星月不相逢 2021-01-04 19:27

Im trying to display the error page in /temp/www/error403.html whenever a 403 error occurs.

This should be whenever a user tries to access the site via https (ssl) a

4条回答
  •  [愿得一人]
    2021-01-04 19:59

    The problem might be that you're trying to server a 403 "Forbidden" error from a webserver that they are forbidden from accessing. Nginx treats the error_page directive as an internal redirect. So it is trying to server https://example.com/error403.html which is also forbidden.

    So you need to make the error page not served out of https like this:

    error_page  403   http://example.com/error403.html
    

    or add the necessary "access allowed" options to the location for the error page path. The way to test this is to access the /error403.html page directly. If you can't accesses that way, it isn't going to work when someone gets an actual 403 error.

提交回复
热议问题