Nginx rewrite: last & break
Maxim Dounin
mdounin at mdounin.ru
Sun Oct 23 15:32:03 UTC 2011
Hello!
On Sat, Oct 22, 2011 at 10:25:29AM -0400, locojohn wrote:
> Nginx User Wrote:
> -------------------------------------------------------
>
> > Adding Maxim's statement above into account,
> > outside a location block,
> > "break" behaves just like "last" does since there
> > are no location
> > directives to run here.
> >
> > Someone just needs to update the docs if this is
> > correct.
> >
>
> I have experienced situations when "rewrite something target last;" in
> the server {} section generates the 503 page, while "rewrite something
> target break;" instead works OK. It means that "break" does not behave
> like "last" in the server section of the virtual host either.
The 500, likely. This might happen with nginx before 1.1.6 due to
completely different reason: if there were no matching location
found, the rewrite directives specified at server level were
executed inside an implicit location again.
It is fixed in 1.1.6:
*) Bugfix: the ngx_http_rewrite_module directives specified at "server"
level were executed twice if no matching locations were defined.
Simple and effective way to prevent such sort of problems is to
always define "location /".
Maxim Dounin
More information about the nginx
mailing list