use certbot-nginx to renew ssl
This commit is contained in:
@@ -3,8 +3,6 @@
|
|||||||
# Define required environment variables
|
# Define required environment variables
|
||||||
declare -A required_vars=(
|
declare -A required_vars=(
|
||||||
["NGINX_SERVER_NAME"]="Nginx server domain"
|
["NGINX_SERVER_NAME"]="Nginx server domain"
|
||||||
["NGINX_SSL_CERT"]="SSL certificate path"
|
|
||||||
["NGINX_SSL_KEY"]="SSL key path"
|
|
||||||
["NGINX_FRONTEND_ROOT"]="Frontend build file path"
|
["NGINX_FRONTEND_ROOT"]="Frontend build file path"
|
||||||
["BACKEND_PORT"]="Backend service port"
|
["BACKEND_PORT"]="Backend service port"
|
||||||
)
|
)
|
||||||
@@ -72,12 +70,6 @@ configure_nginx() {
|
|||||||
# Replace server_name
|
# Replace server_name
|
||||||
if [[ $line =~ ^[[:space:]]*server_name[[:space:]]+ ]]; then
|
if [[ $line =~ ^[[:space:]]*server_name[[:space:]]+ ]]; then
|
||||||
echo " server_name $NGINX_SERVER_NAME www.$NGINX_SERVER_NAME;"
|
echo " server_name $NGINX_SERVER_NAME www.$NGINX_SERVER_NAME;"
|
||||||
# Replace SSL certificate path
|
|
||||||
elif [[ $line =~ ^[[:space:]]*ssl_certificate[[:space:]]+ ]]; then
|
|
||||||
echo " ssl_certificate $NGINX_SSL_CERT;"
|
|
||||||
# Replace SSL key path
|
|
||||||
elif [[ $line =~ ^[[:space:]]*ssl_certificate_key[[:space:]]+ ]]; then
|
|
||||||
echo " ssl_certificate_key $NGINX_SSL_KEY;"
|
|
||||||
# Exactly match the frontend build path setting line
|
# Exactly match the frontend build path setting line
|
||||||
elif [[ $line =~ ^[[:space:]]*set[[:space:]]+\$frontend_build_root[[:space:]]+ ]]; then
|
elif [[ $line =~ ^[[:space:]]*set[[:space:]]+\$frontend_build_root[[:space:]]+ ]]; then
|
||||||
echo " set \$frontend_build_root $NGINX_FRONTEND_ROOT;"
|
echo " set \$frontend_build_root $NGINX_FRONTEND_ROOT;"
|
||||||
@@ -97,11 +89,10 @@ configure_nginx() {
|
|||||||
|
|
||||||
# Execute configuration
|
# Execute configuration
|
||||||
configure_nginx
|
configure_nginx
|
||||||
|
|
||||||
# Test Nginx configuration
|
|
||||||
cp docker/Nginx/nginx.conf /etc/nginx
|
cp docker/Nginx/nginx.conf /etc/nginx
|
||||||
nginx -t
|
|
||||||
|
|
||||||
/etc/init.d/nginx restart
|
echo "Nginx base configuration generated successfully at /etc/nginx/sites-available/default."
|
||||||
|
echo "The script no longer restarts Nginx automatically."
|
||||||
echo "Nginx configuration completed."
|
echo ""
|
||||||
|
echo "NEXT STEP: Run Certbot to install the SSL certificate and automatically configure Nginx:"
|
||||||
|
echo "sudo certbot --nginx -d your_domain.com -d www.your_domain.com"
|
||||||
@@ -24,10 +24,6 @@ server {
|
|||||||
ssl_early_data on;
|
ssl_early_data on;
|
||||||
|
|
||||||
server_name YourDomain www.YourDomain;
|
server_name YourDomain www.YourDomain;
|
||||||
|
|
||||||
# SSL Configuration
|
|
||||||
ssl_certificate path/to/your/certFile;
|
|
||||||
ssl_certificate_key path/to/your/privkeyFile;
|
|
||||||
|
|
||||||
# SSL Optimization
|
# SSL Optimization
|
||||||
ssl_session_timeout 1d;
|
ssl_session_timeout 1d;
|
||||||
|
|||||||
Reference in New Issue
Block a user