Welcome to Centmin Mod Community
Register Now

Nginx nginx.resty not found

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Oxide, May 2, 2016.

Tags:
  1. Oxide

    Oxide Active Member

    502
    29
    28
    Mar 19, 2015
    Ratings:
    +54
    Local Time:
    2:12 PM
    I am trying to use: Redis based IP blacklist for Nginx (LUA) · GitHub


    However, i am recieveing 500 internal server error & this error in error.log:
    Code:
    2016/05/02 13:08:39 [error] 22942#22942: *12 lua entry thread aborted: runtime error: /usr/local/nginx/conf/security_conf/ip_blacklist.lua:64: module 'resty.redis' not found:
        no field package.preload['resty.redis']
        no file '/usr/local/nginx/conf/security_conf/resty/redis.lua'
        no file './resty/redis.lua'
        no file '/usr/local/share/luajit-2.1.0-beta2/resty/redis.lua'
        no file '/usr/local/share/lua/5.1/resty/redis.lua'
        no file '/usr/local/share/lua/5.1/resty/redis/init.lua'
        no file './resty/redis.so'
        no file '/usr/local/lib/lua/5.1/resty/redis.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './resty.so'
        no file '/usr/local/lib/lua/5.1/resty.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
    stack traceback:
    coroutine 0:
        [C]: in function 'require'
        /usr/local/nginx/conf/security_conf/ip_blacklist.lua:64: in function </usr/local/nginx/conf/security_conf/ip_blacklist.lua:1>, client: 95.34.26.106, server: pscentral.net, request: "GET / HTTP/1.1", host: "pscentral.net", referrer: "https://pscentral.net/"
    2016/05/02 13:08:39 [error] 22939#22939: *13 lua entry thread aborted: runtime error: /usr/local/nginx/conf/security_conf/ip_blacklist.lua:64: module 'resty.redis' not found:
        no field package.preload['resty.redis']
        no file '/usr/local/nginx/conf/security_conf/resty/redis.lua'
        no file './resty/redis.lua'
        no file '/usr/local/share/luajit-2.1.0-beta2/resty/redis.lua'
        no file '/usr/local/share/lua/5.1/resty/redis.lua'
        no file '/usr/local/share/lua/5.1/resty/redis/init.lua'
        no file './resty/redis.so'
        no file '/usr/local/lib/lua/5.1/resty/redis.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './resty.so'
        no file '/usr/local/lib/lua/5.1/resty.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
    stack traceback:
    I applied some own modification to ip_blacklist.lua:
    Code:
    local redis_host    = "127.0.0.1"
    local redis_port    = 6379
    
    -- connection timeout for redis in ms. don't set this too high!
    local redis_timeout = 200
    
    -- check a set with this key for blacklist entries
    local redis_key     = "ip_blacklist"
    
    -- cache lookups for this many seconds
    local cache_ttl     = 60

     
  2. eva2000

    eva2000 Administrator Staff Member

    28,988
    6,579
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,767
    Local Time:
    2:12 PM
    Nginx 1.13.x
    MariaDB 5.5
    persistent config setup at /etc/centminmod/custom_config.inc used
    Code (Text):
    ORESTY_LUANGINX='y'
    

    then you recompiled nginx via centmin.sh menu option 4 to enable nginx lua module ?

    not all openresty lua modules are included in centmin mod, only common ones i use, so could be case of some being missing ? did it work previously on centmin mod with nginx lua ?
    lua located at /usr/local/lib/lua/resty
    Code (Text):
    /usr/local/lib/lua/resty:
    total 328K
    drwxr-xr-x 2 root root 4.0K May  2 13:19 .
    drwxr-xr-x 5 root root   38 May  2 13:19 ..
    -rwxr-xr-x 1 root root 6.2K May  2 13:19 aes.lua
    -rwxr-xr-x 1 root root 2.3K May  2 13:19 base64.lua
    -rwxr-xr-x 1 root root 3.5K May  2 13:19 base.lua
    -rwxr-xr-x 1 root root 7.8K May  2 13:19 client.lua
    -rwxrwxr-x 1 root root 5.2K Jan  8  2015 cookie.lua
    -rwxr-xr-x 1 root root  472 May  2 13:19 core.lua
    -rwxr-xr-x 1 root root 1.9K May  2 13:19 ctx.lua
    -rwxr-xr-x 1 root root 1.1K May  2 13:19 exit.lua
    -rwxr-xr-x 1 root root 1.9K May  2 13:19 hash.lua
    -rwxr-xr-x 1 root root  18K May  2 13:19 healthcheck.lua
    -rwxr-xr-x 1 root root 4.4K May  2 13:19 lock.lua
    -rwxr-xr-x 1 root root 4.6K May  2 13:19 lrucache.lua
    -rwxr-xr-x 1 root root 1.2K May  2 13:19 md5.lua
    -rwxr-xr-x 1 root root  15K May  2 13:19 memcached.lua
    -rwxr-xr-x 1 root root 3.1K May  2 13:19 misc.lua
    -rwxr-xr-x 1 root root  20K May  2 13:19 mysql.lua
    -rwxr-xr-x 1 root root 8.5K May  2 13:19 protocol.lua
    -rwxr-xr-x 1 root root  17K May  2 13:19 pureffi.lua
    -rwxr-xr-x 1 root root  612 May  2 13:19 random.lua
    -rwxr-xr-x 1 root root  11K May  2 13:19 redis.lua
    -rwxr-xr-x 1 root root  24K May  2 13:19 regex.lua
    -rwxr-xr-x 1 root root 8.5K May  2 13:19 request.lua
    -rwxr-xr-x 1 root root  19K May  2 13:19 resolver.lua
    -rwxr-xr-x 1 root root 4.1K May  2 13:19 response.lua
    -rwxr-xr-x 1 root root 4.8K May  2 13:19 server.lua
    -rwxr-xr-x 1 root root 1.2K May  2 13:19 sha1.lua
    -rwxr-xr-x 1 root root 1.1K May  2 13:19 sha224.lua
    -rwxr-xr-x 1 root root 1.3K May  2 13:19 sha256.lua
    -rwxr-xr-x 1 root root 1.1K May  2 13:19 sha384.lua
    -rwxr-xr-x 1 root root 1.4K May  2 13:19 sha512.lua
    -rwxr-xr-x 1 root root  236 May  2 13:19 sha.lua
    -rwxr-xr-x 1 root root 9.1K May  2 13:19 shdict.lua
    -rwxrwxr-x 1 root root  12K Feb  9  2015 socket.lua
    -rwxr-xr-x 1 root root  694 May  2 13:19 string.lua
    -rwxr-xr-x 1 root root  436 May  2 13:19 time.lua
    -rwxr-xr-x 1 root root 5.1K May  2 13:19 upload.lua
    -rwxr-xr-x 1 root root 1.5K May  2 13:19 uri.lua
    -rwxr-xr-x 1 root root 3.0K May  2 13:19 var.lua
    -rwxr-xr-x 1 root root  445 May  2 13:19 worker.lua
     
  3. Oxide

    Oxide Active Member

    502
    29
    28
    Mar 19, 2015
    Ratings:
    +54
    Local Time:
    2:12 PM
    yes if i remember right

    Code:
    [root@main-ovh /]# ls -la /usr/local/lib/lua/resty
    total 332
    drwxr-xr-x 2 root root  4096 May  2 13:01 .
    drwxr-xr-x 5 root root  4096 May  2 13:01 ..
    -rwxr-xr-x 1 root root  6299 May  2 13:01 aes.lua
    -rwxr-xr-x 1 root root  2266 May  2 13:01 base64.lua
    -rwxr-xr-x 1 root root  3503 May  2 13:01 base.lua
    -rwxr-xr-x 1 root root  7941 May  2 13:01 client.lua
    -rwxrwxr-x 1 root root  5212 Oct  1  2015 cookie.lua
    -rwxr-xr-x 1 root root   472 May  2 13:01 core.lua
    -rwxr-xr-x 1 root root  1890 May  2 13:01 ctx.lua
    -rwxr-xr-x 1 root root  1099 May  2 13:01 exit.lua
    -rwxr-xr-x 1 root root  1860 May  2 13:01 hash.lua
    -rwxr-xr-x 1 root root 18233 May  2 13:01 healthcheck.lua
    -rwxr-xr-x 1 root root  4451 May  2 13:01 lock.lua
    -rwxr-xr-x 1 root root  4690 May  2 13:01 lrucache.lua
    -rwxr-xr-x 1 root root  1209 May  2 13:01 md5.lua
    -rwxr-xr-x 1 root root 14805 May  2 13:01 memcached.lua
    -rwxr-xr-x 1 root root  3162 May  2 13:01 misc.lua
    -rwxr-xr-x 1 root root 20190 May  2 13:01 mysql.lua
    -rwxr-xr-x 1 root root  8624 May  2 13:01 protocol.lua
    -rwxr-xr-x 1 root root 17182 May  2 13:01 pureffi.lua
    -rwxr-xr-x 1 root root   612 May  2 13:01 random.lua
    -rwxr-xr-x 1 root root 10504 May  2 13:01 redis.lua
    -rwxr-xr-x 1 root root 23829 May  2 13:01 regex.lua
    -rwxr-xr-x 1 root root  8605 May  2 13:01 request.lua
    -rwxr-xr-x 1 root root 18860 May  2 13:01 resolver.lua
    -rwxr-xr-x 1 root root  4125 May  2 13:01 response.lua
    -rwxr-xr-x 1 root root  4881 May  2 13:01 server.lua
    -rwxr-xr-x 1 root root  1202 May  2 13:01 sha1.lua
    -rwxr-xr-x 1 root root  1058 May  2 13:01 sha224.lua
    -rwxr-xr-x 1 root root  1231 May  2 13:01 sha256.lua
    -rwxr-xr-x 1 root root  1058 May  2 13:01 sha384.lua
    -rwxr-xr-x 1 root root  1369 May  2 13:01 sha512.lua
    -rwxr-xr-x 1 root root   236 May  2 13:01 sha.lua
    -rwxr-xr-x 1 root root  9231 May  2 13:01 shdict.lua
    -rwxrwxr-x 1 root root 11516 Feb  9  2015 socket.lua
    -rwxr-xr-x 1 root root   694 May  2 13:01 string.lua
    -rwxr-xr-x 1 root root   436 May  2 13:01 time.lua
    -rwxr-xr-x 1 root root  5155 May  2 13:01 upload.lua
    -rwxr-xr-x 1 root root  1524 May  2 13:01 uri.lua
    -rwxr-xr-x 1 root root  3033 May  2 13:01 var.lua
    -rwxr-xr-x 1 root root   445 May  2 13:01 worker.lua
    
    it looks like redis.lua is there so not sure what went wrong - i am using your github ip_blacklist.lua.
     
  4. eva2000

    eva2000 Administrator Staff Member

    28,988
    6,579
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,767
    Local Time:
    2:12 PM
    Nginx 1.13.x
    MariaDB 5.5
    i only forked that code, never actually used it heh - so could be outdated code that isn't compatible with latest openresty lua-resty-core
     
    • Like Like x 1
  5. Oxide

    Oxide Active Member

    502
    29
    28
    Mar 19, 2015
    Ratings:
    +54
    Local Time:
    2:12 PM
    Well both seems to have same error.

    What I did:

    Apply this into nginx.conf http:
    Code:
    lua_package_path "/usr/local/nginx/conf/security_conf/?.lua;;";
    lua_shared_dict ip_blacklist_cache 10m;
    Place ip_blacklist.lua inside /usr/local/nginx/conf/security_conf/

    Place - inside virtual.conf (or my domains in other words)
    Code:
    access_by_lua_file /usr/local/nginx/conf/security_conf/ip_blacklist.lua;
    ngxreload

    reloads fine, gives 500 error on the specific website i loaded it in.
    i used it fine on other servers, not sure what i did wrong or what went wrong haha :p
     
  6. Oxide

    Oxide Active Member

    502
    29
    28
    Mar 19, 2015
    Ratings:
    +54
    Local Time:
    2:12 PM
    Do I need to specify redis somewhere? Other than in ip_blacklist.lua, perhaps include it in nginx somewhere...
     
  7. Oxide

    Oxide Active Member

    502
    29
    28
    Mar 19, 2015
    Ratings:
    +54
    Local Time:
    2:12 PM
    Woops, changed to :
    lua_package_path "/usr/local/lib/lua/?.lua;;";

    Now no errors appear :) fixed..
     
    • Informative Informative x 1
  8. eva2000

    eva2000 Administrator Staff Member

    28,988
    6,579
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,767
    Local Time:
    2:12 PM
    Nginx 1.13.x
    MariaDB 5.5
    haha was about say use /usr/local/lib/lua/resty but if /usr/local/lib/lua/ works good
    Code (Text):
    ls -lahR /usr/local/lib/lua/     
    /usr/local/lib/lua/:
    total 8.0K
    drwxr-xr-x  5 root root   38 May  2 13:19 .
    drwxr-xr-x. 6 root root 4.0K May  2 13:33 ..
    drwxr-xr-x  3 root root   33 May  2 13:33 5.1
    drwxr-xr-x  2 root root   74 May  2 13:33 ngx
    drwxr-xr-x  2 root root 4.0K May  2 13:33 resty
    
    /usr/local/lib/lua/5.1:
    total 44K
    drwxr-xr-x 3 root root  33 May  2 13:33 .
    drwxr-xr-x 5 root root  38 May  2 13:19 ..
    -rwxr-xr-x 1 root root 41K May  2 13:33 cjson.so
    drwxr-xr-x 2 root root   6 May  2 13:19 redis
    
    /usr/local/lib/lua/5.1/redis:
    total 0
    drwxr-xr-x 2 root root  6 May  2 13:19 .
    drwxr-xr-x 3 root root 33 May  2 13:33 ..
    
    /usr/local/lib/lua/ngx:
    total 20K
    drwxr-xr-x 2 root root   74 May  2 13:33 .
    drwxr-xr-x 5 root root   38 May  2 13:19 ..
    -rwxr-xr-x 1 root root 2.3K May  2 13:33 balancer.lua
    -rwxr-xr-x 1 root root 3.7K May  2 13:33 ocsp.lua
    -rwxr-xr-x 1 root root 3.4K May  2 13:33 semaphore.lua
    -rwxr-xr-x 1 root root 4.9K May  2 13:33 ssl.lua
    
    /usr/local/lib/lua/resty:
    total 328K
    drwxr-xr-x 2 root root 4.0K May  2 13:33 .
    drwxr-xr-x 5 root root   38 May  2 13:19 ..
    -rwxr-xr-x 1 root root 6.2K May  2 13:33 aes.lua
    -rwxr-xr-x 1 root root 2.3K May  2 13:33 base64.lua
    -rwxr-xr-x 1 root root 3.5K May  2 13:33 base.lua
    -rwxr-xr-x 1 root root 7.8K May  2 13:33 client.lua
    -rwxrwxr-x 1 root root 5.2K Jan  8  2015 cookie.lua
    -rwxr-xr-x 1 root root  472 May  2 13:33 core.lua
    -rwxr-xr-x 1 root root 1.9K May  2 13:33 ctx.lua
    -rwxr-xr-x 1 root root 1.1K May  2 13:33 exit.lua
    -rwxr-xr-x 1 root root 1.9K May  2 13:33 hash.lua
    -rwxr-xr-x 1 root root  18K May  2 13:33 healthcheck.lua
    -rwxr-xr-x 1 root root 4.4K May  2 13:33 lock.lua
    -rwxr-xr-x 1 root root 4.6K May  2 13:33 lrucache.lua
    -rwxr-xr-x 1 root root 1.2K May  2 13:33 md5.lua
    -rwxr-xr-x 1 root root  15K May  2 13:33 memcached.lua
    -rwxr-xr-x 1 root root 3.1K May  2 13:33 misc.lua
    -rwxr-xr-x 1 root root  20K May  2 13:33 mysql.lua
    -rwxr-xr-x 1 root root 8.5K May  2 13:33 protocol.lua
    -rwxr-xr-x 1 root root  17K May  2 13:33 pureffi.lua
    -rwxr-xr-x 1 root root  612 May  2 13:33 random.lua
    -rwxr-xr-x 1 root root  11K May  2 13:33 redis.lua
    -rwxr-xr-x 1 root root  24K May  2 13:33 regex.lua
    -rwxr-xr-x 1 root root 8.5K May  2 13:33 request.lua
    -rwxr-xr-x 1 root root  19K May  2 13:33 resolver.lua
    -rwxr-xr-x 1 root root 4.1K May  2 13:33 response.lua
    -rwxr-xr-x 1 root root 4.8K May  2 13:33 server.lua
    -rwxr-xr-x 1 root root 1.2K May  2 13:33 sha1.lua
    -rwxr-xr-x 1 root root 1.1K May  2 13:33 sha224.lua
    -rwxr-xr-x 1 root root 1.3K May  2 13:33 sha256.lua
    -rwxr-xr-x 1 root root 1.1K May  2 13:33 sha384.lua
    -rwxr-xr-x 1 root root 1.4K May  2 13:33 sha512.lua
    -rwxr-xr-x 1 root root  236 May  2 13:33 sha.lua
    -rwxr-xr-x 1 root root 9.1K May  2 13:33 shdict.lua
    -rwxrwxr-x 1 root root  12K Feb  9  2015 socket.lua
    -rwxr-xr-x 1 root root  694 May  2 13:33 string.lua
    -rwxr-xr-x 1 root root  436 May  2 13:33 time.lua
    -rwxr-xr-x 1 root root 5.1K May  2 13:33 upload.lua
    -rwxr-xr-x 1 root root 1.5K May  2 13:33 uri.lua
    -rwxr-xr-x 1 root root 3.0K May  2 13:33 var.lua
    -rwxr-xr-x 1 root root  445 May  2 13:33 worker.lua


    maybe drop ip_blacklist.lua into /usr/local/lib/lua/resty as well
     
  9. eva2000

    eva2000 Administrator Staff Member

    28,988
    6,579
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,767
    Local Time:
    2:12 PM
    Nginx 1.13.x
    MariaDB 5.5