fix:Fix the hard-coded issue with the turn domain name
This commit is contained in:
@@ -5,6 +5,7 @@ declare -A required_vars=(
|
||||
["NGINX_SERVER_NAME"]="Nginx server domain"
|
||||
["NGINX_FRONTEND_ROOT"]="Frontend build file path"
|
||||
["BACKEND_PORT"]="Backend service port"
|
||||
["TURN_REALM"]="TURN server domain name"
|
||||
)
|
||||
|
||||
# Validate environment variables
|
||||
@@ -70,6 +71,7 @@ configure_nginx() {
|
||||
-e "s/YourDomain/$NGINX_SERVER_NAME/g" \
|
||||
-e "s|path/to/PrivyDrop/frontend|$NGINX_FRONTEND_ROOT|g" \
|
||||
-e "s/localhost:3001/localhost:$BACKEND_PORT/g" \
|
||||
-e "s/TurnServerName/$TURN_REALM/g" \
|
||||
"$NGINX_TEMPLATE" > "$TEMP_NGINX"
|
||||
|
||||
# Copy the configuration file to the target location
|
||||
@@ -78,12 +80,31 @@ configure_nginx() {
|
||||
rm "$TEMP_NGINX"
|
||||
}
|
||||
|
||||
# Configure nginx.conf with variable substitution
|
||||
configure_nginx_conf() {
|
||||
echo "Configuring nginx.conf..."
|
||||
|
||||
NGINX_CONF_TEMPLATE="$SCRIPT_DIR/nginx.conf"
|
||||
echo "reading $NGINX_CONF_TEMPLATE ..."
|
||||
TEMP_NGINX_CONF=$(mktemp)
|
||||
|
||||
# Use sed to replace variables in nginx.conf
|
||||
sed -e "s/TurnServerName/$TURN_REALM/g" \
|
||||
"$NGINX_CONF_TEMPLATE" > "$TEMP_NGINX_CONF"
|
||||
|
||||
# Copy the configuration file to the target location
|
||||
cp "$TEMP_NGINX_CONF" /etc/nginx/nginx.conf
|
||||
rm "$TEMP_NGINX_CONF"
|
||||
}
|
||||
|
||||
# Execute configuration
|
||||
configure_nginx
|
||||
cp backend/docker/Nginx/nginx.conf /etc/nginx
|
||||
configure_nginx_conf
|
||||
|
||||
echo "Nginx base configuration generated successfully at /etc/nginx/sites-enabled/default."
|
||||
echo "Nginx configuration files generated successfully:"
|
||||
echo " - /etc/nginx/sites-enabled/default (site configuration)"
|
||||
echo " - /etc/nginx/nginx.conf (main configuration with TURN routing)"
|
||||
echo "The script no longer restarts Nginx automatically."
|
||||
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"
|
||||
echo "sudo certbot --nginx -d your_domain.com -d www.your_domain.com -d turn.your_domain.com"
|
||||
@@ -135,9 +135,9 @@ listen 443 quic reuseport; # Listen on UDP port 443 for QUIC and HTTP/3 # 'reuse
|
||||
|
||||
}
|
||||
|
||||
server { # Add a server block for Certbot to install certificates for turn.privydrop.app
|
||||
server { # Add a server block for Certbot to install certificates for TURN server
|
||||
listen 80;
|
||||
server_name turn.privydrop.app;
|
||||
server_name TurnServerName;
|
||||
|
||||
# Only process Let's Encrypt validation requests
|
||||
location /.well-known/acme-challenge/ {
|
||||
|
||||
@@ -24,7 +24,7 @@ stream {
|
||||
|
||||
# Use SNI hostname to determine traffic destination
|
||||
map $ssl_preread_server_name $backend {
|
||||
turn.privydrop.app turns_backend; # If accessing the turn subdomain, hand it over to Coturn
|
||||
TurnServerName turns_backend; # If accessing the turn subdomain, hand it over to Coturn
|
||||
default website_backend; # All other domains are handed over to the website
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user