Skip to content
This repository has been archived by the owner on Feb 14, 2018. It is now read-only.

ERROR: *2 lua entry thread aborted: runtime error: access_by_lua #53

Closed
przbadu opened this issue Jan 7, 2016 · 2 comments
Closed

ERROR: *2 lua entry thread aborted: runtime error: access_by_lua #53

przbadu opened this issue Jan 7, 2016 · 2 comments

Comments

@przbadu
Copy link

przbadu commented Jan 7, 2016

First curl gives this error:

2016/01/07 11:59:02 [error] 17199#0: *1 lua entry thread aborted: runtime error: ...bapps/openresty_nginx_app/openresty/lualib/nginx-jwt.lua:7: Environment variable JWT_SECRET not set
stack traceback:
coroutine 0:
    [C]: in function 'require'
    access_by_lua(nginx.conf:59):2: in function <access_by_lua(nginx.conf:59):1>, client: 127.0.0.1, server: localhost, request: "GET /secure HTTP/1.0", host: "my.host.com"

Second curl gives this error:

2016/01/07 10:13:11 [error] 27439#0: *2 lua entry thread aborted: runtime error: access_by_lua(nginx.conf:58):2: loop or previous error loading module 'nginx-jwt'
stack traceback:
coroutine 0:
    [C]: in function 'require'
    access_by_lua(nginx.conf:58):2: in function <access_by_lua(nginx.conf:58):1>, client: 127.0.0.1, server: localhost, request: "GET /secure HTTP/1.0", host: "my.host.com"

NOTE: I have already setup JWT_SECRET in my .zshrc file, and it looks like lua is not taking that.

Installed openresty with:

$ curl -R -O https://openresty.org/download/ngx_openresty-1.9.7.1.tar.gz
$ tar xvf ngx_openresty-1.9.7.1.tar.gz
$ cd ngx_openresty-1.9.7.1/
" $ ./configure " not working for WebFaction, so --prefix installation directory to ~/bin
./configure \
  --prefix=/home/<myuser>/webapps/openresty_nginx_app/openresty \
  --with-luajit \
  --with-ipv6 \
  --with-http_postgres_module \
  --with-http_gunzip_module \
  --with-http_secure_link_module \
  --with-http_gzip_static_module \
  --without-http_redis_module \
  --without-http_redis2_module \
  --without-http_xss_module \
  --without-http_memc_module \
  --without-http_rds_json_module \
  --without-http_rds_csv_module \
  --without-lua_resty_memcached \
  --without-lua_resty_mysql \
  --without-http_ssi_module \
  --without-http_autoindex_module \
  --without-http_fastcgi_module \
  --without-http_uwsgi_module \
  --without-http_scgi_module \
  --without-http_memcached_module \
  --without-http_empty_gif_module
$ make
$ make install
  1. Downloaded nginx-jwt from https://github.com/auth0/nginx-jwt/releases

  2. moved it under the nginx directory that is installed by openresty:

    $ cd /home//webapps/openresty_nginx_app/openresty/nginx

Directory Structure:

|-- openresty/
|---- bin/
|---- luajit/
|---- lualib/
|---- nginx/
|------- client_body_temp/
|------- conf/
|------- html/
|------- logs/
|------- lua/
|--------- basexx.lua
|--------- nginx-jwt.lua
|--------- resty/
|----------- evp.lua
|----------- hmac.lua
|----------- jwt.lua
|--------- version.txt
|------- proxy_temp/
|------- sbin

config/nginx.conf

http {

.....

#nginx-jwt
  lua_package_path '/home/<myuser>/webapps/openresty_nginx_app/openresty/lua/?.lua;;';

  server {
    listen       23439;
    server_name  localhost;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location /check {
      default_type text/html;
      content_by_lua '
      ngx.say("<h1>Should work now with openresty</h1>")
      ';
    }

    # nginx-lua secure url
    location /secure {
      access_by_lua '
      local jwt = require("nginx-jwt")
      jwt.auth()
      ';

      proxy_pass http://my.host.com/secure;
    }

    .........

  }
}

NOTE: http://my.host.com/check is working fine. problem is with http://my.host.com/secure

@przbadu
Copy link
Author

przbadu commented Jan 7, 2016

Having same problem in my centos 7 server : ISSUE-51

So, I have downloaded, extracted and scp all contents into the server

@przbadu
Copy link
Author

przbadu commented Jan 7, 2016

Having a closer look at error, I found that, it was a issue with

local secret = os.getenv("JWT_SECRET")

i.e JWT_SECRET set in my .zshrc are not picking up by lua.

I manually replace this script to debug:

-- local secret = os.getenv("JWT_SECRET")
local secret = "some secret"

And the app is working. Still I have to figure out, how to set Env variables for lua?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant