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. 效果
 
 
5. 说明
以上参考代码使用了mirror 功能,对于lapis 端口使用默认的情况,会看到终端不停地输出信息(死循环了),因为我修改为了9090自定义端口,就不会存在类似的问题

posted on   荣锋亮  阅读(1040)  评论(0编辑  收藏  举报

编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2015-11-16 微软发布了ASP.NET WebHooks预览版

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5
点击右上角即可分享
微信分享提示