参考

apisix中, 没有nginx一样的的静态内容路由配置,
可以启动一个nginx容器返回静态内容, 然后在apisix中配置路由的upstream到nginx入口

但其实不必这样, 使用apisix的echo插件或serverless插件都可以实现返回静态内容

方法

echo, 返回静态内容

"echo": {  
	"body": "any static content"  
}

serverless 返回动态的content

return function(conf, ctx)
    local cjson = require "cjson"
    local client_ip = ngx.var.remote_addr
    local real_ip = ngx.var.http_cf_connecting_ip
    if real_ip then
        client_ip = real_ip
    end
    local response = { ip = client_ip, msg = "docker service only" }
    ngx.header.content_type = "application/json"
    ngx.say(cjson.encode(response))
    ngx.exit(ngx.HTTP_OK)
end

具体见:https://www.api2o.com/zh/blog/apisix/direct-return-body#serverless-%E8%BF%94%E5%9B%9E%E5%8A%A8%E6%80%81%E7%9A%84content

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐