chaoslawful/lua-nginx-module — Issue #68: Headers not returned from subrequest
Author: Fry-kun
Created: 2011-11-22 22:57:41+00:00
State: open

lua-nginx 5fcb1a7b8bc61f5ee244593b2b38ee90d058ed23
nginx 1.1.8

I'm trying to have nginx add a custom return header, but lua code doesn't see it. If it matters, my original code sets it in a redis2 internal location, but for simplicity the example below uses echo

nginx config:

location /foo {
content_by_lua 'local u=require("utils");local res=ngx.location.capture("/bar"); ngx.print(u.pformat(res))';
}
location /bar {
echo "baz";
add_header "Foo" "Bar";
}

Results:

$ curl -v 'http://localhost/bar'
* About to connect() to localhost port 80 (#0)
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /bar HTTP/1.1
> User-Agent: curl/7.21.3-DEV (x86_64-unknown-linux-gnu) libcurl/7.21.3-DEV OpenSSL/1.0.0 zlib/1.2.5 libssh2/1.2.4
> Host: localhost
> Accept: */*
>
< HTTP/1.1 200 OK
< Server:
< Date: Tue, 22 Nov 2011 22:55:08 GMT
< Content-Type: application/octet-stream
< Transfer-Encoding: chunked
< Connection: keep-alive
< Foo: Bar
<
baz
* Connection #0 to host localhost left intact
* Closing connection #0

$ curl -v 'http://localhost/foo'
* About to connect() to localhost port 80 (#0)
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /foo HTTP/1.1
> User-Agent: curl/7.21.3-DEV (x86_64-unknown-linux-gnu) libcurl/7.21.3-DEV OpenSSL/1.0.0 zlib/1.2.5 libssh2/1.2.4
> Host: localhost
> Accept: */*
>
< HTTP/1.1 200 OK
< Server:
< Date: Tue, 22 Nov 2011 22:55:37 GMT
< Content-Type: application/octet-stream
< Transfer-Encoding: chunked
< Connection: keep-alive
<
__unnamed__ = {
["status"] = 200;
["body"] = "baz\
";
["header"] = {
["Content-Type"] = "application/octet-stream";
};
};
* Connection #0 to host localhost left intact
* Closing connection #0