Answer the question
In order to leave comments, you need to log in
How to make nginx run lua scripts via luaJIT?
I want to put the jwt validation logic 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;
}
}
lua_package_path "/opt/test/?.lua;;";
$ curl test
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:
Answer the question
In order to leave comments, you need to log in
You need to install LuaJIT and rebuild nginx with LuaJIT instead of Lua.
In Debian, the following patch was applied for this ( bug ):
diff -ruN nginx-1.6.0.orig/debian/modules/nginx-lua/config nginx-1.6.0/debian/modules/nginx-lua/config
--- nginx-1.6.0.orig/debian/modules/nginx-lua/config 2014-04-24 13:23:46.000000000 -0300
+++ nginx-1.6.0/debian/modules/nginx-lua/config 2014-07-24 03:48:10.816586362 -0300
@@ -131,9 +131,9 @@
ngx_feature="Lua library in /usr/"
ngx_feature_path="/usr/include/lua5.1"
if [ $NGX_RPATH = YES ]; then
- ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -llua5.1"
+ ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1"
else
- ngx_feature_libs="-L/usr/lib -lm -llua5.1"
+ ngx_feature_libs="-L/usr/lib -lm -lluajit-5.1"
fi
. auto/feature
fi
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question