basic API to be used in swarm mode

This commit is contained in:
bunkerity
2021-03-12 10:42:31 +01:00
parent 781e4c8cbb
commit 7509ec2f2c
5 changed files with 64 additions and 0 deletions

View File

@@ -126,3 +126,5 @@ USE_ANTIBOT="${USE_ANTIBOT-no}"
ANTIBOT_RECAPTCHA_SCORE="${ANTIBOT_RECAPTCHA_SCORE-0.7}"
ANTIBOT_SESSION_SECRET="${ANTIBOT_SESSION_SECRET-random}"
USE_CROWDSEC="${USE_CROWDSEC-no}"
USE_API="${USE_API-no}"
API_URI="${API_URI-random}"

View File

@@ -305,6 +305,17 @@ else
replace_in_file "/etc/nginx/nginx.conf" "%USE_CROWDSEC%" ""
fi
# API
if [ "$USE_API" = "yes" ] ; then
replace_in_file "/etc/nginx/nginx.conf" "%USE_API%" "include /etc/nginx/api.conf;"
if [ "$API_URI" = "random" ] ; then
API_URI="/$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
fi
replace_in_file "/usr/local/lib/lua/api.lua" "%API_URI%" "$API_URI"
else
replace_in_file "/etc/nginx/nginx.conf" "%USE_API%" ""
fi
# create empty logs
touch /var/log/access.log
touch /var/log/error.log