mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
/extensions using lua
This commit is contained in:
parent
f3fdf336d3
commit
72003095b3
@ -42,15 +42,27 @@ http {
|
||||
|
||||
include /etc/nginx/ext.d/*/http-ctx.conf;
|
||||
|
||||
lua_shared_dict WS_TOKENS 10m;
|
||||
init_by_lua_block {
|
||||
WS_TOKEN_EXPIRES = 10;
|
||||
|
||||
local cjson = require("cjson");
|
||||
local io = require("io");
|
||||
|
||||
EXTENSIONS = {};
|
||||
local extensions_dir_path = "/etc/nginx/ext.d";
|
||||
for extension in io.popen("ls " .. extensions_dir_path):lines() do
|
||||
local manifest_file = assert(io.open(extensions_dir_path .. "/" .. extension .. "/manifest.json", "r"));
|
||||
local manifest = cjson.decode(manifest_file:read("*all"));
|
||||
manifest_file:close();
|
||||
EXTENSIONS[manifest["name"]] = manifest;
|
||||
end
|
||||
}
|
||||
|
||||
#PROD server {
|
||||
#PROD listen 80;
|
||||
#PROD server_name localhost;
|
||||
#PROD return 301 https://$host$request_uri;
|
||||
#PROD }
|
||||
|
||||
#PROD lua_shared_dict WS_TOKENS 10m;
|
||||
#PROD init_by_lua_block {
|
||||
#PROD WS_TOKEN_EXPIRES = 10;
|
||||
#PROD }
|
||||
|
||||
server {
|
||||
@ -84,6 +96,14 @@ http {
|
||||
}
|
||||
}
|
||||
|
||||
location /extensions {
|
||||
default_type "application/json";
|
||||
content_by_lua_block {
|
||||
local cjson = require("cjson");
|
||||
ngx.say(cjson.encode(EXTENSIONS));
|
||||
}
|
||||
}
|
||||
|
||||
location /kvmd/ws {
|
||||
#PROD auth_basic off;
|
||||
#PROD access_by_lua_block {
|
||||
|
||||
@ -40,6 +40,7 @@ RUN pacman -Syy \
|
||||
nginx-mainline \
|
||||
ustreamer \
|
||||
socat \
|
||||
lua51-cjson \
|
||||
&& env MAKEPKGOPTS="--skipchecksums --skippgpcheck" user-packer -S --noconfirm nginx-mainline-mod-lua \
|
||||
&& pacman -Sc --noconfirm
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user