I was digging the reason why add_header in nginx config doesn't work for a
subrequest and I've found this in ngx_http_headers_filter_module.c:
if ((conf->expires == NGX_HTTP_EXPIRES_OFF && conf->headers == NULL)
|| r != r->main)
Is there a particular reason to skip the filter for everything that's not a
I'm still struggling with the subrequests. And it looks like I've solved
the most of everything, except for this.
In a few modules I've found a trick:
if (r != r->connection->data)
r->connection->data = r;
I've put this code to my post subrequest callback and before
If I remove this code, the request processing will hang dead.
With this code my simple tests work fine. But when I try to make a
subrequest from a subrequest I get something like this in the error log:
2015/03/16 02:55:39 [alert] 73485#0: *2 subrequest: "/lalala/?" logged
again, client: 127.0.0.1, server: localhost, request: "POST /test1
HTTP/1.1", subrequest: "/lalala/", host: "localhost"
And it looks like the subrequest processing is called twice.
My question is about the proper scenario to handle the situation and about
what exactly r != r->connection->data means.