Welcome! Log In Create A New Profile

Advanced

Re: error ngx_http_send_header

Maxim Dounin
May 17, 2018 09:14AM
Hello!

On Wed, May 16, 2018 at 01:05:50PM -0700, Dk Jack wrote:

> Hi Maxim,
>
> I am sending the response in the request handler which I registered for
>
> in the NGX_HTTP_SERVER_REWRITE_PHASE handler. In my handler, I have the

In a rewrite phase handler you are _not_ expected to return a
response. If you do return it, you have to be careful to properly
cancel additional request processing.

Moreover, the server rewrite phase is _not_ executed for
locations. Instead, it is a phase for rewrites affecting the
whole server block. The configuration example you've provided
makes no sense for a module which works in the server rewrite
phase.

For returning a custom response in a specifically set location it
might be better idea to use the content phase, or, even simplier,
to register a location-specific content handler. See empty gif
module sources for a relatively simple example.

> following code to avoid responding multiple times as well. Still, I am getting
>
> the error.
>
> if (r->main->count > 1)
> return NGX_DECLINED;

This is not expected to prevent anything from being executed
multiple times. Rather, it will prevent your code from executing
when there is more than one reference to the request.

You may want to read some guides on writing nginx modules, as it
is more or less clear you don't understand basics. In particular,
Evan Miller's one might be a good start:

https://www.evanmiller.org/nginx-modules-guide.html

Refer to the Development Guide for more advanced subjects:

http://nginx.org/en/docs/dev/development_guide.html

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

error ngx_http_send_header

dnj0496 111 May 16, 2018 01:04PM

Re: error ngx_http_send_header

Ranier Vf 25 May 16, 2018 01:24PM

Re: error ngx_http_send_header

Maxim Dounin 31 May 16, 2018 03:12PM

Re: error ngx_http_send_header

dnj0496 29 May 16, 2018 04:08PM

Re: error ngx_http_send_header

tokers 35 May 16, 2018 10:30PM

Re: error ngx_http_send_header

Maxim Dounin 53 May 17, 2018 09:14AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 72
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 254 on July 05, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready