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

本文介绍如何在安装Lapis的基础上,通过配置新版Nginx及OpenResty实现stream特性,并利用mirror功能完成服务的无缝对接。文章提供具体步骤与代码示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

备注: 
  为了解决安装了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自定义端口,就不会存在类似的问题
 
 
 
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值