Welcome! Log In Create A New Profile


Re: error ngx_http_send_header

Maxim Dounin
May 17, 2018 09:14AM

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

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:


Refer to the Development Guide for more advanced subjects:


Maxim Dounin
nginx-devel mailing list
Subject Author Views Posted

error ngx_http_send_header

dnj0496 178 May 16, 2018 01:04PM

Re: error ngx_http_send_header

Ranier Vf 53 May 16, 2018 01:24PM

Re: error ngx_http_send_header

Maxim Dounin 64 May 16, 2018 03:12PM

Re: error ngx_http_send_header

dnj0496 62 May 16, 2018 04:08PM

Re: error ngx_http_send_header

tokers 82 May 16, 2018 10:30PM

Re: error ngx_http_send_header

Maxim Dounin 88 May 17, 2018 09:14AM

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

Online Users

Guests: 73
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready