I once wrote a similar module, just directly in the handler, return NGX_HTTP_MOVED_TEMPORARILY;
see: https://github.com/flygoast/ngx_http_url_hash_module At 2013-09-11 05:33:31,"Michael Ellery" <[email protected]> wrote: >Hello, > >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: > ><code> > ngx_table_elt_t *set_location = ngx_list_push(&r->headers_out.headers); > if (set_location == NULL) { > SXEL2("ERROR: failed to add location header"); > return -1; > } > > r->err_status = NGX_HTTP_MOVED_TEMPORARILY; > > set_location->hash = 1; > ngx_str_set(&set_location->key, "Location"); > set_location->value.len = len; > set_location->value.data = location; > > ngx_http_clear_location(r); > > ngx_http_finalize_request(r, NGX_HTTP_MOVED_TEMPORARILY); > ></code> > >and then returning NGX_OK from my handler. > >This seems to work in the sense that I do get the expected 302 at my client - >HOWEVER, I also get a segfault: > >2013/09/10 13:26:22 [alert] 28910#0: worker process 29362 exited on signal 11 > >...which seems to be happening at ngx_http_proxy_module.c:645 > > ngx_http_set_ctx(r, ctx, ngx_http_proxy_module); > >because r->ctx is NULL at this point. > >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? > >TIA, >Mike Ellery > >_______________________________________________ >nginx-devel mailing list >[email protected] >http://mailman.nginx.org/mailman/listinfo/nginx-devel
_______________________________________________ nginx-devel mailing list [email protected] http://mailman.nginx.org/mailman/listinfo/nginx-devel
