nginx config fix

This commit is contained in:
Joby 2024-10-23 17:09:11 -06:00
parent 738ef88259
commit ad2904619d

View file

@ -8,19 +8,19 @@ fi
# Install requirements # Install requirements
echo "Installing required packages..." echo "Installing required packages..."
apt-get install -y nginx-extras apt-get install -y nginx-extras nginx-module-njs
# Add load_module directive to nginx.conf if not present # Add load_module directive to nginx.conf if not present
echo "Adding load_module directive to nginx.conf if needed..." 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 if ! grep -q "^load_module.*ngx_http_js_module.so" /etc/nginx/nginx.conf; then
# Create temporary file # Create temporary file
sed '/^events {/i load_module modules/ngx_http_js_module.so;' /etc/nginx/nginx.conf > /tmp/nginx.conf.tmp sed '/^events {/i load_module /usr/lib/nginx/modules/ngx_http_js_module.so;' /etc/nginx/nginx.conf > /tmp/nginx.conf.tmp
# Check if the modification was successful # Check if the modification was successful
if nginx -t -c /tmp/nginx.conf.tmp; then if nginx -t -c /tmp/nginx.conf.tmp; then
mv /tmp/nginx.conf.tmp /etc/nginx/nginx.conf mv /tmp/nginx.conf.tmp /etc/nginx/nginx.conf
else else
rm /tmp/nginx.conf.tmp rm /tmp/nginx.conf.tmp
echo "Failed to modify nginx.conf safely. Please add 'load_module modules/ngx_http_js_module.so;' manually." echo "Failed to modify nginx.conf safely. Please add 'load_module /usr/lib/nginx/modules/ngx_http_js_module.so;' manually."
exit 1 exit 1
fi fi
fi fi