returning a 302 from ACCESS_PHASE handler

Maxim Dounin mdounin at mdounin.ru
Wed Sep 11 11:35:46 UTC 2013


Hello!

On Tue, Sep 10, 2013 at 02:33:31PM -0700, Michael Ellery wrote:

> I have an ACCESS_PHASE handler and, in some cases, I want to 
> return a 302 to a different domain.  I'm currently doing
> the following:

[...]

> I suspect that calling ngx_http_finalize_request from my handler 
> is causing this, although I have not conclusively
> proven this.
> 
> Does someone know if it's possible to return a redirect from 
> ACCESS handlers and, if so, what is the proper way to
> accomplish it?

You shouldn't call finalize request yourself, just return 
NGX_HTTP_MOVED_TEMPORARILY instead.  Take a look at 
ngx_http_core_access_phase() in src/http/ngx_http_core_module.c to 
see how it's handled.

-- 
Maxim Dounin
http://nginx.org/en/donation.html



More information about the nginx-devel mailing list