nginx $http_upgrade 在 openresty access_by_lua_block

nginx $http_upgrade in openresty access_by_lua_block

在 OPENRESTY 中 NGINX 的名称是什么或如何调用 $http_upgrade access_by_lua_block

所以我可以在这里使用它

access_by_lua_block {
   ???
}

您可以使用 ngx.var.VARIABLE or ngx.req.get_headers API 来获取任何请求的值 header:

access_by_lua_block {
    ngx.log(ngx.INFO, ngx.var.http_upgrade)
    ngx.log(ngx.INFO, ngx.req.get_headers()['upgrade'])
}

来自文档:

Note that the ngx.var.HEADER API call, which uses core $http_HEADER variables, may be more preferable for reading individual request headers.