29 lines
800 B
Bash
Executable File
29 lines
800 B
Bash
Executable File
#!/bin/bash
|
|
# Script Version: 01
|
|
# Description: Replaces 'listen 443 ssl' with 'listen 80' in Nginx configuration files under /etc/nginx/sites-enabled/
|
|
|
|
# Directory containing Nginx site configurations
|
|
CONFIG_DIR="/etc/nginx/sites-enabled"
|
|
|
|
# Iterate over each file in the configuration directory
|
|
for FILE in "$CONFIG_DIR"/*; do
|
|
# Check if the file is a regular file
|
|
if [ -f "$FILE" ]; then
|
|
# Replace 'listen 443 ssl' with 'listen 80'
|
|
sed -i 's/listen 443 ssl;/listen 80;/g' "$FILE"
|
|
fi
|
|
done
|
|
|
|
# Test Nginx configuration
|
|
nginx -t
|
|
|
|
# Check if the configuration test was successful
|
|
if [ $? -eq 0 ]; then
|
|
# Reload Nginx to apply changes
|
|
systemctl reload nginx
|
|
echo "Nginx reloaded successfully."
|
|
else
|
|
echo "Nginx configuration test failed. Please check the configuration files."
|
|
fi
|
|
|