I am new to nginx server, i am trying to validate all request through auth_request module it is working as expected, but in error page configuration it is not working, I have 2 error page configuration 1 for 401 and 1 for 403

    error_page 401 = @error401;
    location @error401 {
        return 302 /login?state=secure;
   error_page 403 =@error403;
    location = @error403 {
       return 302 /accessDenied;

but when server return 401 it is working perfectly, and when server return 403 then it show default 403 page, i wanted it to land on /accessDenied page. can you please help!!!

  • Your error_page 403 is missing a space!! – Richard Smith Apr 23 '18 at 9:28
  • Thanks Richard, i tried with space also but no luck – Nilesh Patidar Apr 23 '18 at 9:52

I do not have the reputation to comment. The location line for the 403 should not have an equals sign.

i.e. location = @error403 { should be location @error403 {

The syntax for the commands you are using and how to use them (although your usage seems fine) are well summarised here, http://nginx.org/en/docs/http/ngx_http_core_module.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.