Welcome! Log In Create A New Profile

Advanced

Re: custom 403 error page quirk

Maxim Dounin
November 01, 2010 04:36AM
Hello!

On Mon, Nov 01, 2010 at 03:02:21AM -0400, megamic wrote:

> Hi
>
> I have been trying to imlement a custom 403 error page - to be
> triggered when the request method is not in HEAD,GET,POST. I started
> with something like this (note I was specifically triggering the 403
> error for GET requests for testing):
>
> root /htdocs
>
> location = /403.html {
> internal;
> }
>
> error_page 403 = /403.html;
>
> if ($request_method !~ ^(POST)$ ) {
> return 403;
> }
>
> location / {
> index index.html;
> }
>
> For some reason, the above config *always* caused nginx internal 403
> error page to be generated - instead of my custom page at
> /htdoc/403.html.
>
> After scouring forums and whatnot, I found a suggestion, which is to put
> the if() inside the location block - like:
>
> location / {
> index index.html;
>
> if ($request_method !~ ^(POST)$ ) {
> return 403;
> }
> }
>
> Doing this and everything seemed to work. I just don't understand why -
> can someone explain this?

http://nginx.org/pipermail/nginx/2010-October/023353.html

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

custom 403 error page quirk

megamic November 01, 2010 03:02AM

Re: custom 403 error page quirk

Maxim Dounin November 01, 2010 04:36AM

Re: custom 403 error page quirk

megamic November 01, 2010 05:33AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 310
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready