/extensions using lua

This commit is contained in:
Devaev Maxim 2018-11-12 04:03:21 +03:00
parent f3fdf336d3
commit 72003095b3
5 changed files with 26 additions and 5 deletions

View File

@ -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 {

View File

@ -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