lapis 集成openresty最新版本cjson 问题的解决

备注:

为了解决安装了lapis、同时又希望使用新版nginx 以及openresty 的特性(stream 。。。)

1. 解决方法

参考:

https://github.com/leafo/lapis/issues/539

luarocks install lua-cjson2

2. openresty 以及luarocks

最好使用源码安装,可以参考相关文章

3. 测试

lapis new  --lua

// 修改下nginx.conf 为了集成openresty 的stream 特性,以及nginx的mirror,这样就可以两全其美了

stream{

server{

listen 1234;

content_by_lua_block{

ngx.say("Hello, Lua!")

}

}

}

location/{

mirror /mirror;

default_type text/html;

content_by_lua'

require("lapis").serve("app")

}

location /mirror{

proxy_pass http://127.0.0.1:8080$request_uri;

proxy_pass_request_body off;

proxy_set_header Content-Length "";

proxy_set_header  X-Original-URI $request_uri;

}

lapis server

4. 说明

以上参考代码使用了mirror 功能,对于lapis 端口使用默认的情况,会看到终端不停地输出

信息(死循环了),因为我修改为了9090自定义端口,就不会存在类似的问题

你可能感兴趣的:(lapis 集成openresty最新版本cjson 问题的解决)