crowdsecurity / lua-cs-bouncer

MIT License
10 stars 13 forks source link

attempt to call method 'set_timeout' (a nil value) #37

Closed masikrus closed 11 months ago

masikrus commented 1 year ago
2022/10/30 12:57:22 [error] 3322517#3322517: *1 lua entry thread aborted: runtime error: /usr/local/lua/crowdsec/crowdsec.lua:97: attempt to call method 'set_timeout' (a nil value)
stack traceback:
coroutine 0:
        /usr/local/lua/crowdsec/crowdsec.lua: in function 'get_http_request'
        /usr/local/lua/crowdsec/crowdsec.lua:262: in function 'live_query'
        /usr/local/lua/crowdsec/crowdsec.lua:383: in function 'allowIp'
        /usr/local/lua/crowdsec/crowdsec.lua:411: in function 'Allow'
        access_by_lua(crowdsec_nginx.conf:17):3: in main chunk, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", host: "localhost"

help...

LaurenceJJones commented 1 year ago

Could you provide the output of your configuration With api key removed Here an example configuration https://github.com/crowdsecurity/lua-cs-bouncer/blob/eb5de9c364fd4990147d1b0962d6b90e393bdcff/config_example.conf

masikrus commented 1 year ago

i have not standard port of crowdsec 8089 and i have CentOS 8

cat /etc/crowdsec/bouncers/crowdsec-nginx-bouncer.conf | grep -v API_KEY
ENABLED=true
API_URL=http://127.0.0.1:8089
CACHE_EXPIRATION=1
# bounce for all type of remediation that the bouncer can receive from the local API
BOUNCING_ON_TYPE=all
FALLBACK_REMEDIATION=ban
REQUEST_TIMEOUT=3000
UPDATE_FREQUENCY=10
# live or stream
MODE=live
# exclude the bouncing on those location
EXCLUDE_LOCATION=
#those apply for "ban" action
# /!\ REDIRECT_LOCATION and RET_CODE can't be used together. REDIRECT_LOCATION take priority over RET_CODE
BAN_TEMPLATE_PATH=/var/lib/crowdsec/lua/templates/ban.html
REDIRECT_LOCATION=
RET_CODE=
#those apply for "captcha" action
# ReCaptcha Secret Key
SECRET_KEY=123123
# Recaptcha Site key
SITE_KEY=123123
CAPTCHA_TEMPLATE_PATH=/var/lib/crowdsec/lua/templates/captcha.html
CAPTCHA_EXPIRATION=3600
LaurenceJJones commented 1 year ago

Have you made sure all dependencies are installed?

System modules:
        "libnginx-mod-http-lua"
        "luarocks"
        "lua5.1"
        "gettext-base"
 luarocks: 
   lua-resty-http
   lua-cjson

edit I presumed your using nginx

masikrus commented 1 year ago

Yap, all of dependencies installed and i use nginx 1.22 with mod lua

masikrus commented 1 year ago

i fix that error. in Centos default pkg use https://github.com/liseen/lua-resty-http but you code use https://github.com/ledgetech/lua-resty-http...

BUT! Now i have new error with cjson...

2022/11/01 13:00:42 [error] 2441476#2441476: *1 lua entry thread aborted: runtime error: /usr/local/lua/crowdsec/crowdsec.lua:284: attempt to call field 'decode' (a nil value)
masikrus commented 1 year ago

and that i fixed in file /usr/local/lua/crowdsec/crowdsec.lua need add cpath

package.cpath = package.cpath .. ";/usr/share/lua/5.1/?.so"

with you module cjson.so path