【问题标题】:How to add multiple access_by_lua_file directive under same location = /_sample如何在同一位置添加多个 access_by_lua_file 指令 = /_sample
【发布时间】:2020-06-15 18:38:03
【问题描述】:

在 location 下使用 openidc 模块自省并在下面调用 using,

 Policy section
#
location = /_sample {
    internal;
    set $api_name "sample"; 
    access_by_lua_file /etc/nginx/path/oauth_introspection.lua;
     Proxypass......
}

现在我想包含下面的 lua 文件以添加一些内容并在同一请求下验证某些内容。

 Policy section
#
location = /_sample {
    internal;
    set $api_name "sample"; 
    access_by_lua_file /etc/nginx/path/oauth_introspection.lua;
        access_by_lua_file /etc/nginx/path/do_something.lua; //Error with duplicate
     Proxypass......
}

而我的 oauth_introspection.lua 有这个 openidc 内省逻辑,

local res, err = require("resty.openidc").introspect(opts)

【问题讨论】:

    标签: nginx lua lua-resty-openidc


    【解决方案1】:

    access_by_lua_file 只能使用一次。您必须在 lua 文件中组合您的代码:

    location = /_sample {
        internal;
        set $api_name "sample"; 
        access_by_lua_file /etc/nginx/path/action_sample.lua;
        Proxypass......
    }
    

    action_sample.lua:

    local res, err = require("resty.openidc").introspect(opts)
    
    -- do something or 
    loadfile("/etc/nginx/path/do_something.lua")(opts)
    
    

    【讨论】:

      猜你喜欢
      • 2012-10-29
      • 1970-01-01
      • 2012-01-20
      • 1970-01-01
      • 2014-05-08
      • 2014-04-10
      • 1970-01-01
      • 2018-01-25
      • 2018-06-21
      相关资源
      最近更新 更多