mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
big rewrite of extensions
This commit is contained in:
6
configs/nginx/apps/kvm/manifest.json
Normal file
6
configs/nginx/apps/kvm/manifest.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "KVM",
|
||||
"description": "Open KVM session in a web browser",
|
||||
"path": "/kvm.html",
|
||||
"place": 0
|
||||
}
|
||||
@@ -6,7 +6,7 @@ worker_processes 4;
|
||||
# error_log /tmp/nginx.error.log;
|
||||
error_log stderr;
|
||||
|
||||
include /etc/nginx/ext.d/*/main-ctx.conf;
|
||||
include /etc/nginx/apps/*/main-ctx.conf;
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
@@ -40,7 +40,7 @@ http {
|
||||
server 127.0.0.1:8082 fail_timeout=0s max_fails=0;
|
||||
}
|
||||
|
||||
include /etc/nginx/ext.d/*/http-ctx.conf;
|
||||
include /etc/nginx/apps/*/http-ctx.conf;
|
||||
|
||||
lua_shared_dict WS_TOKENS 10m;
|
||||
init_by_lua_block {
|
||||
@@ -49,14 +49,16 @@ http {
|
||||
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 apps = {};
|
||||
local apps_dir_path = "/etc/nginx/apps";
|
||||
for app in io.popen("ls " .. apps_dir_path):lines() do
|
||||
local manifest_file = assert(io.open(apps_dir_path .. "/" .. app .. "/manifest.json", "r"));
|
||||
local manifest = cjson.decode(manifest_file:read("*all"));
|
||||
manifest_file:close();
|
||||
EXTENSIONS[manifest["name"]] = manifest;
|
||||
apps[app] = manifest;
|
||||
end
|
||||
|
||||
APPS_JSON = cjson.encode(apps);
|
||||
}
|
||||
|
||||
#PROD server {
|
||||
@@ -84,7 +86,7 @@ http {
|
||||
index index.html;
|
||||
}
|
||||
|
||||
location /wsauth {
|
||||
location /ws_auth {
|
||||
# Workaround for Safari: https://bugs.webkit.org/show_bug.cgi?id=80362
|
||||
#PROD access_by_lua_block {
|
||||
#PROD local token = ngx.encode_base64(ngx.sha1_bin(ngx.var.http_Authorization));
|
||||
@@ -96,11 +98,10 @@ http {
|
||||
}
|
||||
}
|
||||
|
||||
location /extensions {
|
||||
location /get_apps {
|
||||
default_type "application/json";
|
||||
content_by_lua_block {
|
||||
local cjson = require("cjson");
|
||||
ngx.say(cjson.encode(EXTENSIONS));
|
||||
ngx.say(APPS_JSON);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +111,7 @@ http {
|
||||
#PROD local token = ngx.var.cookie_WS_ACCESS_TOKEN;
|
||||
#PROD local value, _ = ngx.shared.WS_TOKENS:get(token);
|
||||
#PROD if value == nil then
|
||||
#PROD ngx.exec("/wsauth");
|
||||
#PROD ngx.exec("/ws_auth");
|
||||
#PROD end
|
||||
#PROD }
|
||||
rewrite ^/kvmd/ws$ /ws break;
|
||||
@@ -164,6 +165,6 @@ http {
|
||||
proxy_ignore_headers X-Accel-Buffering;
|
||||
}
|
||||
|
||||
include /etc/nginx/ext.d/*/server-ctx.conf;
|
||||
include /etc/nginx/apps/*/server-ctx.conf;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user