lua-resty-qless-web UI 界面运行
lua-resty-qless-web 是 lua-resty-qless 的web 管理界面以及lua-resty-template 模版引擎开发的,里面实现了一个简单的
路由功能
备注: demo 运行使用docker-compose ,简单修改了官方demo 有问题的部分,后边会添加集成lua-resty-qless 的docker-compose
运行方式
环境准备
- docker-compose 文件
version: "3"
services:
app:
build: ./
ports:
- "8080:80"
volumes:
- "./app/:/opt/app/"
- "./nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf"
redis:
image: redis
ports:
- "6379:6379"
- nginx 配置
worker_processes 1;
user root;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
lua_code_cache off;
gzip on;
resolver 127.0.0.11;
real_ip_header X-Forwarded-For;
real_ip_recursive on;
lua_package_path '/opt/app/lua-resty-qless-web/lib/?.lua;;';
init_by_lua_block {
local Qless_Web = require("resty.qless-web")
}
server {
listen 80;
server_name localhost;
charset utf-8;
root html;
default_type text/html;
# 配置web
location /web {
default_type text/html;
location /web/__static {
internal;
rewrite ^/web/__static(.*) $1 break;
root /opt/app/lua-resty-qless-web/static/;
}
content_by_lua_block {
local resty_qless = require "resty.qless"
local qless, err = resty_qless.new({
host = "redis",
port = 6379,
})
if not qless then
return ngx.say("Qless.new(): ", err)
end
local Qless_Web = require("resty.qless-web")
local web = Qless_Web:new({ client = qless, uri_prefix = "/web" })
web:run()
}
}
location / {
default_type text/html;
index index.html;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
- lua-resty-qless-web 代码
此代码直接从github clone,使用中需要配置lua 包的位置,在nginx.conf 中
lua_package_path '/opt/app/lua-resty-qless-web/lib/?.lua;;';
运行&&界面
- 启动
docker-compose up -d
- 效果
访问地址 http://localhost:8080/web/
参考资料
https://github.com/rongfengliang/lua-resty-qless-web-docker-compose
https://github.com/ledgetech/lua-resty-qless
https://github.com/hamishforbes/lua-resty-qless-web