Hello,
using a current nginx 1.5.3 compiled with the lastest lua-nginx-module and ngx_http_v2 module i am trying to achieve the following:
Set a "Link" header containing resources to be pushed on a http/2 connection. This is supposed to be interpreted by the http2 filter when turning on "http2_push_preload on;".
However, it seems that this header is never seen by the http2 filter as opposed to the nginx builtin "add_header" directive.
This does not work:
location / {
http2_push_preload on;
location ~ \.html$ {
expires 0;
try_files $uri =404;
access_by_lua_block {
ngx.header["Link"] = "</css/c.css>; as=style; rel=preload, </js/j.js>; as=script; rel=preload"
}
}
}
This does work:
location / {
http2_push_preload on;
location ~ \.html$ {
expires 0;
add_header Link "</css/c.css>; as=style; rel=preload, </js/j.js>; as=script; rel=preload";
try_files $uri =404;
access_by_lua_block {
}
}
}
Of course i would prefer to be able to use the access_by_lua version to be able to set these headers dynamically.
Somehow add_header and ngx.header (as well as ngx_resp.add_header and even more_set_headers) are not equivalent. So i thought it might be simply a phase issue, but after turning on debug log i have learned that the http2 filter that is supposed to parse this Link-header is running in content phase: 15, much later then access_by_lua.
Another mystery here is that the header set by builtin add_header is only seen in lua-nginx-module as late as body_filter_by_lua and log_by_lua.
What am i missing here?