Welcome! Log In Create A New Profile

Advanced

Re: error_page can not work in if directive

Maxim Dounin
December 25, 2012 10:28AM
Hello!

On Tue, Dec 25, 2012 at 10:09:45AM -0500, xinghua_hi wrote:

> thank you very much, but i sitll want to know why error_page can't work
> normally in if block.
> I see the error_page 's context can be " if in location" in the document.
>
> the whole location conf like below, error_page can not work:
>
> client_max_body_size 50k;
> location / {
> set $var "haha";
> if ($var = "haha") {
> error_page 413 /413.html;
> }
> }
>
> but
>
> client_max_body_size 50k;
> location / {
> error_page 413 /413.html;
> }
> it works!

The 413 error is generated once location configuration is
determinded, and this happens before location-level rewrite module
directives (the "if" directive in particular) are executed. Hence
error_page 413 configure inside the "if" doesn't make any
difference.

(Please also note that in general it's a good idea to avoid using
the "if" directive, see http://wiki.nginx.org/IfIsEvil.)

--
Maxim Dounin
http://nginx.com/support.html

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

error_page can not work in if directive

xinghua_hi December 25, 2012 08:06AM

Re: error_page can not work in if directive

xinghua_hi December 25, 2012 09:36AM

Re: error_page can not work in if directive

Maxim Dounin December 25, 2012 09:44AM

Re: error_page can not work in if directive

xinghua_hi December 25, 2012 10:09AM

Re: error_page can not work in if directive

Maxim Dounin December 25, 2012 10:28AM

Re: error_page can not work in if directive

xinghua_hi December 25, 2012 11:47AM

Re: error_page can not work in if directive

Maxim Dounin December 25, 2012 12:26PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 176
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