Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whatever I do, I always get nil #76

Open
alexanschiffer opened this issue Apr 2, 2024 · 0 comments
Open

Whatever I do, I always get nil #76

alexanschiffer opened this issue Apr 2, 2024 · 0 comments

Comments

@alexanschiffer
Copy link

alexanschiffer commented Apr 2, 2024

This is the error from error log:

2024/04/02 18:02:08 [error] 7#0: *1 [lua] whitelist.lua:96: failed to instantiate a rest1111111: nil, client: 172.22.0.5, server: _, request: "GET / HTTP/1.1", host: "domain.tld"
2024/04/02 18:02:08 [error] 7#0: *1 invalid URL prefix in "fine", client: 172.22.0.5, server: _, request: "GET / HTTP/1.1", host: "domain.tld"

This is lua code. The goal is to check if rate limit is reached. If the rate limit is reached, then it should run the code and if not, the else block:

-- First check for rate limit
local limit_count = require "resty.limit.count"
local lim, err = limit_count.new("my_limit_count_store", 20, 60)

--if rate limited run application
if not lim then
ngx.log(ngx.ERR, "failed to instantiate a resty.limit.count object: ", err) -- This is done for testing if this gets called


(...) -- some lua code which already work
else
        ngx.log(ngx.ERR, "failed to instantiate a rest1111111: ", err)
        ngx.var.check = "fine"
end

the http block contains:

        lua_shared_dict my_req_store 100m;
        lua_shared_dict my_conn_store 100m;
        lua_shared_dict my_limit_conn_store 100m;
        lua_shared_dict my_limit_req_store 100m;
        lua_shared_dict my_limit_count_store 100m;

    init_by_lua_block {
        require "resty.core"
    }

Whatever I do, I always get the same error. I already tried

if not lim then
to
if lim then

and

local limit_conn = require "resty.limit.conn"
local lim, err = limit_conn.new("my_limit_conn_store", 10, 10, 0.5)

but always with the same result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant