diff options
author | Devaev Maxim <[email protected]> | 2018-11-14 07:42:43 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-11-14 07:42:43 +0300 |
commit | 2a540f7bb91bc8425c0fb4eabee1ecee4ec7cf85 (patch) | |
tree | 4896e265b089f4f75a8155bffd5b166c06f2da3c /configs | |
parent | c5544349d2bc5981ed843a7f71c8326364da4a3e (diff) |
big rewrite of extensions
Diffstat (limited to 'configs')
-rw-r--r-- | configs/nginx/apps/.gitignore (renamed from configs/nginx/ext.d/.gitignore) | 0 | ||||
-rw-r--r-- | configs/nginx/apps/kvm/manifest.json | 6 | ||||
-rw-r--r-- | configs/nginx/nginx.conf | 27 |
3 files changed, 20 insertions, 13 deletions
diff --git a/configs/nginx/ext.d/.gitignore b/configs/nginx/apps/.gitignore index e69de29b..e69de29b 100644 --- a/configs/nginx/ext.d/.gitignore +++ b/configs/nginx/apps/.gitignore diff --git a/configs/nginx/apps/kvm/manifest.json b/configs/nginx/apps/kvm/manifest.json new file mode 100644 index 00000000..710af6f0 --- /dev/null +++ b/configs/nginx/apps/kvm/manifest.json @@ -0,0 +1,6 @@ +{ + "name": "KVM", + "description": "Open KVM session in a web browser", + "path": "/kvm.html", + "place": 0 +} diff --git a/configs/nginx/nginx.conf b/configs/nginx/nginx.conf index ce4b5799..22271d20 100644 --- a/configs/nginx/nginx.conf +++ b/configs/nginx/nginx.conf @@ -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; } } |