hotfix - fix API in autoconf swarm mode
This commit is contained in:
parent
3bb164395e
commit
01eba177d2
@ -220,6 +220,7 @@ if [ "$USE_API" = "yes" ] ; then
|
||||
API_URI="/$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
|
||||
echo "[*] Generated API URI : $API_URI"
|
||||
fi
|
||||
replace_in_file "/etc/nginx/api.conf" "%API_URI%" "$API_URI"
|
||||
else
|
||||
replace_in_file "/etc/nginx/nginx.conf" "%USE_API%" ""
|
||||
fi
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
local M = {}
|
||||
local api_list = {}
|
||||
local api_whitelist_ip = {%API_WHITELIST_IP%}
|
||||
local iputils = require "resty.iputils"
|
||||
local whitelist = iputils.parse_cidrs(api_whitelist_ip)
|
||||
local ip = ngx.var.remote_addr
|
||||
|
||||
api_list["^/ping$"] = function ()
|
||||
return true
|
||||
@ -13,7 +13,7 @@ api_list["^/reload$"] = function ()
|
||||
end
|
||||
|
||||
function M.is_api_call (api_uri)
|
||||
if iputils.ip_in_cidrs(ip, whitelist) and ngx.var.request_uri:sub(1, #api_uri) .. "/" == api_uri .. "/" then
|
||||
if iputils.ip_in_cidrs(ngx.var.remote_addr, whitelist) and ngx.var.request_uri:sub(1, #api_uri) .. "/" == api_uri .. "/" then
|
||||
for uri, code in pairs(api_list) do
|
||||
if string.match(ngx.var.request_uri:sub(#api_uri + 1), uri) then
|
||||
return true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user