diff options
author | Devaev Maxim <[email protected]> | 2018-11-12 04:03:21 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2018-11-12 04:03:21 +0300 |
commit | 72003095b3376684a79c0ddb7a27cb33c83fe6e3 (patch) | |
tree | 5c7689dfc525d0d9a9e6cbf270880ae628404006 /configs/nginx | |
parent | f3fdf336d3afe8981beeec51d8ed4fd8310bcc0c (diff) |
/extensions using lua
Diffstat (limited to 'configs/nginx')
-rw-r--r-- | configs/nginx/ext.d/noop/http-ctx.conf | 0 | ||||
-rw-r--r-- | configs/nginx/ext.d/noop/main-ctx.conf | 0 | ||||
-rw-r--r-- | configs/nginx/ext.d/noop/server-ctx.conf | 0 | ||||
-rw-r--r-- | configs/nginx/nginx.conf | 30 |
4 files changed, 25 insertions, 5 deletions
diff --git a/configs/nginx/ext.d/noop/http-ctx.conf b/configs/nginx/ext.d/noop/http-ctx.conf deleted file mode 100644 index e69de29b..00000000 --- a/configs/nginx/ext.d/noop/http-ctx.conf +++ /dev/null diff --git a/configs/nginx/ext.d/noop/main-ctx.conf b/configs/nginx/ext.d/noop/main-ctx.conf deleted file mode 100644 index e69de29b..00000000 --- a/configs/nginx/ext.d/noop/main-ctx.conf +++ /dev/null diff --git a/configs/nginx/ext.d/noop/server-ctx.conf b/configs/nginx/ext.d/noop/server-ctx.conf deleted file mode 100644 index e69de29b..00000000 --- a/configs/nginx/ext.d/noop/server-ctx.conf +++ /dev/null diff --git a/configs/nginx/nginx.conf b/configs/nginx/nginx.conf index ecc93b79..644f9694 100644 --- a/configs/nginx/nginx.conf +++ b/configs/nginx/nginx.conf @@ -42,17 +42,29 @@ 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 { #PROD listen 443 ssl http2; server_name localhost; @@ -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 { |