crowdsecurity / cs-nginx-bouncer

CrowdSec bouncer for Nginx
MIT License
48 stars 8 forks source link

Lua runtime error: no request found #44

Closed exentio closed 1 year ago

exentio commented 1 year ago

Hello, after installing the CrowdSec engine I moved to this guide for the Nginx bouncer, and since I use Arch Linux I used this AUR package to install it. After some trial and error to solve issues related to finding the libs (mainly specifying to luarocks to install the deps for Lua 5.1) I reached a dead end, as I get this error whenever I enable the config:

2023/06/20 23:00:53 [error] 8759#8759: *1 lua entry thread aborted: runtime error: /usr/share/lua/5.1/resty/core/var.lua:71: no request found
stack traceback:
coroutine 0:
        [C]: in function 'error'
        /usr/share/lua/5.1/resty/core/var.lua:71: in function '__index'
        access_by_lua(crowdsec.conf:14):3: in function <access_by_lua(crowdsec.conf:14):1>, client: X.X.X.X, server: exentio.sexy, request: "GET / HTTP/2.0", host: "exentio.sexy"

Currently this is my config, the standard one doesn't work because the AUR package installs the bouncer in /etc/nginx/lua rather than in /usr/local/lua:

lua_package_path '$prefix/lua/plugins/crowdsec/?.lua;;';
lua_shared_dict crowdsec_cache 50m;
resolver 1.1.1.1 ipv6=off;
lua_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
init_by_lua_block {
        cs = require "crowdsec"
        local ok, err = cs.init("/etc/crowdsec/bouncers/crowdsec-nginx-bouncer.conf", "crowdsec-nginx-bouncer/v1.0.5")
        if ok == nil then
                ngx.log(ngx.ERR, "[Crowdsec] " .. err)
                error()
        end
        ngx.log(ngx.ALERT, "[Crowdsec] Initialisation done")
}

access_by_lua_block {
        local cs = require "crowdsec"
        cs.Allow(ngx.var.remote_addr)
}

What should I do?

exentio commented 1 year ago

I love opening issues on Github because problems fix themselves afterward.
I have no idea how it fixed itself after a whole day but I'm hoping it won't break.