Skip to content

Commit

Permalink
stop or remove nginx form host after nginx container ssl configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
udkumar committed Nov 21, 2023
1 parent e583ad9 commit a547541
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions docker/auto_ssl_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ copy_ssl_certificate() {
cp -r "$cert_path" "$docker_volume_path" || { echo "Failed to copy SSL certificate"; exit 1; }
}

# Stop or remove Nginx on host
stop_or_remove_nginx_host() {
echo "Stopping or removing Nginx on host..."
systemctl stop nginx || { echo "Failed to stop Nginx on host"; exit 1; }
# Remove Nginx instead of just stopping it
# apt-get remove -y nginx || { echo "Failed to remove Nginx from host"; exit 1; }
}

# Start Nginx container
start_nginx_container() {
echo "Starting Nginx container: $1..."
Expand All @@ -79,6 +87,8 @@ setup_automatic_ssl_renewal() {
(crontab -l 2>/dev/null; echo "0 3 * * * certbot renew --quiet --renew-hook 'docker restart $NGINX_CONTAINER_NAME'") | crontab - || { echo "Failed to setup automatic SSL certificate renewal"; exit 1; }
}



# Main execution
stop_nginx_container "$NGINX_CONTAINER_NAME"
free_up_port_80
Expand Down

0 comments on commit a547541

Please sign in to comment.