nginx config fix
This commit is contained in:
parent
11c6f69c35
commit
738ef88259
2 changed files with 15 additions and 2 deletions
|
@ -10,6 +10,21 @@ fi
|
|||
echo "Installing required packages..."
|
||||
apt-get install -y nginx-extras
|
||||
|
||||
# Add load_module directive to nginx.conf if not present
|
||||
echo "Adding load_module directive to nginx.conf if needed..."
|
||||
if ! grep -q "^load_module.*ngx_http_js_module.so" /etc/nginx/nginx.conf; then
|
||||
# Create temporary file
|
||||
sed '/^events {/i load_module modules/ngx_http_js_module.so;' /etc/nginx/nginx.conf > /tmp/nginx.conf.tmp
|
||||
# Check if the modification was successful
|
||||
if nginx -t -c /tmp/nginx.conf.tmp; then
|
||||
mv /tmp/nginx.conf.tmp /etc/nginx/nginx.conf
|
||||
else
|
||||
rm /tmp/nginx.conf.tmp
|
||||
echo "Failed to modify nginx.conf safely. Please add 'load_module modules/ngx_http_js_module.so;' manually."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Create the fail2ban check script
|
||||
echo "Creating fail2ban check script..."
|
||||
tee /usr/local/bin/check_fail2ban.sh << 'SCRIPT'
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
load_module modules/ngx_http_js_module.so;
|
||||
|
||||
js_import /etc/nginx/modules-available/check_ban.js;
|
||||
js_set $exec_check_ban check_ban.checkBan;
|
||||
|
||||
|
|
Loading…
Reference in a new issue