Hello
I am trying to make x-accel-redirect feature serve external url and pass response headers from origin response which contained X-Accel-Redirect header. Inside location after x-accel internal redirect I can access headers from origin response using $upstream_http_HEADER or ngx.var.upstream_http_HEADER in lua. Problem is that I don't know the names of headers that will be sent by origin upstream. I tried to get them by iterating through ngx.resp.get_headers() but it doesn't contain them.
origin upstream response:
foo:bar
X-Accel-Redirect:/x-accel-redirect/some_resource
Then location below will be used:
location /x-accel-redirect/ {
internal;
content_by_lua_block {
ngx.header["foo"] = ngx.var.upstream_http_foo
local h, err = ngx.resp.get_headers()
for k, v in pairs(h) do
ngx.say(k .. ":" .. v)
end
}
}
response is:
< HTTP/1.1 200 OK
< Content-Type: text/csv;charset=utf-8
< Date: Thu, 19 Sep 2019 16:13:33 GMT
< Server: openresty
< Vary: Accept-Encoding
< foo: bar
< Content-Length: 62
< Connection: keep-alive
<
connection:keep-alive
content-type:text/csv;charset=utf-8
I was able to read Foo header from origin response and pass it downstream but I can't list it using ngx.resp.get_headers().
Thanks for help
Leszek