Update 2025-04-13_16:21:50
This commit is contained in:
29
ssl_certificate_delete.sh
Executable file
29
ssl_certificate_delete.sh
Executable file
@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
# Script Version: 01
|
||||
# Description: Removes ssl_certificate and ssl_certificate_key directives from Nginx configuration files in /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
|
||||
# Remove lines containing ssl_certificate or ssl_certificate_key
|
||||
sed -i '/^\s*ssl_certificate\s\+/d' "$FILE"
|
||||
sed -i '/^\s*ssl_certificate_key\s\+/d' "$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
|
||||
|
Reference in New Issue
Block a user