【问题标题】:nginx $http_upgrade in openresty access_by_lua_blocknginx $http_upgrade 在 openresty access_by_lua_block
【发布时间】:2021-05-15 04:21:30
【问题描述】:

在 OPENRESTY access_by_lua_block 中,NGINX 的 $http_upgrade 叫什么名字或怎么称呼

所以我可以在这里使用它

access_by_lua_block {
   ???
}

【问题讨论】:

    标签: nginx lua openresty


    【解决方案1】:

    您可以使用ngx.var.VARIABLEngx.req.get_headers API 来获取任何请求标头的值:

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

    来自文档:

    请注意,ngx.var.HEADER API 调用使用核心 $http_HEADER 变量,可能更适合读取单个请求标头。

    【讨论】:

      猜你喜欢
      • 2018-08-25
      • 2020-09-30
      • 1970-01-01
      • 2020-09-14
      • 2022-08-05
      • 2021-03-10
      • 1970-01-01
      • 1970-01-01
      • 2021-08-04
      相关资源
      最近更新 更多