How do I get nginx to run lua scripts via LuaJIT?

I want to put the logic of checking jwt on the shoulders of nginx: https://github.com/auth0/nginx-jwt

The server has the following configuration:

server {

        listen 80;
        server_name test;

        location / {
                access_by_lua '
                local jwt = require("nginx-jwt")
                jwt.auth()
                ';
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header Host $http_host;
                proxy_pass http://127.0.0.1:1338;
        }

}

Specified the location of lua scripts in nginx. conf:

lua_package_path "/opt/test/?.lua;;";

Reloading nginx, accessing http:

$ curl test

I get 500 error, in the nginx logs:

2016/09/27 15:01:57 [error] 25541#0: *399 lua entry thread aborted: runtime error: /opt/test/resty/evp.lua:4: module 'ffi' not found:

Did not code on Lua. It turned out that there are two Lua execution environments: lua proper and luajit. It turned out that the ffi module is some kind of a thing with the ability to execute C code, and it is executed only through luajit. In my case, the scripts are executed via lua, and it ends with this error (I checked in the REPL).

I've already done everything. I installed the OpenResty distribution, built it, installed it - there is no effect. Question - how do I make nginx run these scripts using LuaJIT ?

UPD

My nginx uses lua (not LuaJIT):

# ldd /usr/sbin/nginx | grep -i lua
liblua5.1.so.0 => /usr/lib/x86_64-linux-gnu/liblua5.1.so.0  (0x00007f64935f7000)
 1
Author: Matvey Safronov, 2016-09-27

2 answers

There is a solution not purely on the question: you can put https://github.com/facebook/luaffifb. This module is almost the full version of ffi for lua (there is one unrealized feature, but it is quite rarely used). Collect with libs lua 5.1 (you have it), instructions in the repository.

 3
Author: val says Reinstate Monica, 2016-09-28 12:18:56

Content_by_lua_file, but you also need to enter the default type

 1
Author: Zibilzibugel, 2018-02-06 04:21:32