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.
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;
}
}
On Tue, Dec 25, 2012 at 11:47:58AM -0500, xinghua_hi wrote:
will return 404, but 413.haha.html exists my root dir。I see the debug log ,
find some log like
http finalize request: 404, “/413…html?”
obviously, nginx takes $var as an empty string, I think the reason is also
that 413 error is generated before set directive? so , how to use variable
in error_page uri?
Same problem here: the “set” directive isn’t executed, and hence
the $var isn’t “haha” but uninitialized and evaluates to an empty
string.
You have to make $var variable available by other means (e.g. set
the variable at server level, or make it available via map{}
directive).
}
}
the key problem is how can i pass the $var to location /413.html? I try
it , the second $var is empty(I also wonder about the result because I
remember when internal redirect, the location can share the variable) 。
And the same problem here: “set $var “haha”;” in the location /
isn’t executed, and hence $var remains uninitialized.
thanks, but a new question comming。
I try to resolve my problem according to your method:
(1)
“set" is also an location-level rewrite module directive, so the conf
like
this
location / {
root XXX;
set $var “haha”;
error_page 413 /413.${var}.html;
}
will return 404, but 413.haha.html exists my root dir。I see the debug
log ,
find some log like
http finalize request: 404, “/413…html?”
obviously, nginx takes $var as an empty string, I think the reason is
also
that 413 error is generated before set directive? so , how to use
variable
in error_page uri?
(2)
if I writer conf like this:
location / {
set $var “haha”;
error_page 413 /413.html;
}
the key problem is how can i pass the $var to location /413.html? I
try
it , the second $var is empty(I also wonder about the result because I
remember when internal redirect, the location can share the variable) 。
Thank you .
Posted at Nginx Forum:
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.