api - whitelist IP/network for API

This commit is contained in:
florian
2021-04-26 22:22:34 +02:00
parent a3cfb50b4d
commit 5ce41edc03
7 changed files with 13 additions and 8 deletions

View File

@@ -128,4 +128,5 @@ ANTIBOT_SESSION_SECRET="${ANTIBOT_SESSION_SECRET-random}"
USE_CROWDSEC="${USE_CROWDSEC-no}"
USE_API="${USE_API-no}"
API_URI="${API_URI-random}"
API_WHITELIST_IP="${API_WHITELIST_IP-192.168.0.0/16 172.16.0.0/12 10.0.0.0/8}"
SWARM_MODE="${SWARM_MODE-no}"

View File

@@ -220,7 +220,8 @@ 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"
list=$(spaces_to_lua "$API_WHITELIST_IP")
replace_in_file "/usr/local/lib/lua/api.lua" "%API_WHITELIST_IP%" "$list"
else
replace_in_file "/etc/nginx/nginx.conf" "%USE_API%" ""
fi