101 lines
3.2 KiB
Bash
Executable file
101 lines
3.2 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Script to deploy VSCode nginx configuration to the server
|
|
|
|
set -e
|
|
|
|
SERVER_IP="147.45.152.129"
|
|
SERVER_USER="root"
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
VSCODE_NGINX_CONF="$PROJECT_ROOT/mnemo_cards_web_v2/deploy/vscode-nginx.conf"
|
|
|
|
echo "🚀 Deploying VSCode nginx configuration..."
|
|
echo "Server: $SERVER_IP"
|
|
echo "Config file: $VSCODE_NGINX_CONF"
|
|
echo ""
|
|
|
|
# Check if config file exists
|
|
if [ ! -f "$VSCODE_NGINX_CONF" ]; then
|
|
echo "❌ Config file not found: $VSCODE_NGINX_CONF"
|
|
exit 1
|
|
fi
|
|
|
|
echo "📤 Uploading nginx configuration..."
|
|
scp "$VSCODE_NGINX_CONF" "$SERVER_USER@$SERVER_IP:/tmp/vscode-nginx.conf"
|
|
|
|
echo ""
|
|
echo "⚙️ Installing configuration on server..."
|
|
|
|
ssh "$SERVER_USER@$SERVER_IP" << 'ENDSSH'
|
|
set -e
|
|
|
|
echo "📋 Moving config to nginx sites-available..."
|
|
mv /tmp/vscode-nginx.conf /etc/nginx/sites-available/vscode.mnemo-cards.online
|
|
|
|
echo "🔗 Creating symbolic link in sites-enabled..."
|
|
ln -sf /etc/nginx/sites-available/vscode.mnemo-cards.online /etc/nginx/sites-enabled/vscode.mnemo-cards.online
|
|
|
|
echo "✅ Configuration installed"
|
|
|
|
echo ""
|
|
echo "📊 Checking nginx configuration syntax..."
|
|
/usr/sbin/nginx -t
|
|
|
|
echo ""
|
|
echo "🔄 Reloading nginx..."
|
|
systemctl reload nginx
|
|
|
|
echo "✅ nginx reloaded successfully"
|
|
|
|
echo ""
|
|
echo "📊 Checking SSL certificates..."
|
|
if [ -d "/etc/letsencrypt/live/vscode.mnemo-cards.online" ]; then
|
|
echo "✅ Let's Encrypt certificates found"
|
|
ls -la /etc/letsencrypt/live/vscode.mnemo-cards.online/
|
|
else
|
|
echo "⚠️ Let's Encrypt certificates not found"
|
|
echo "You may need to obtain certificates with:"
|
|
echo " sudo certbot certonly --standalone -d vscode.mnemo-cards.online"
|
|
fi
|
|
|
|
echo ""
|
|
echo "📊 Checking rate limiting zones in main nginx config..."
|
|
if grep -q "vscode_general" /etc/nginx/nginx.conf; then
|
|
echo "✅ Rate limiting zones are configured"
|
|
else
|
|
echo "⚠️ Rate limiting zones not found in main config"
|
|
echo "Adding rate limiting zones..."
|
|
|
|
# Backup current config
|
|
cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
|
|
|
|
# Add rate limiting zones in http block
|
|
sed -i '/http {/a\ # Rate limiting zones for VSCode Server\n limit_req_zone $binary_remote_addr zone=vscode_general:10m rate=100r/m;\n limit_req_zone $binary_remote_addr zone=vscode_login:10m rate=5r/m;' /etc/nginx/nginx.conf
|
|
|
|
echo "✅ Rate limiting zones added"
|
|
|
|
echo ""
|
|
echo "📊 Testing updated configuration..."
|
|
/usr/sbin/nginx -t
|
|
|
|
echo ""
|
|
echo "🔄 Reloading nginx again..."
|
|
systemctl reload nginx
|
|
fi
|
|
|
|
ENDSSH
|
|
|
|
echo ""
|
|
echo "✅ Done!"
|
|
echo ""
|
|
echo "🌐 VSCode Server should now be accessible at:"
|
|
echo " https://vscode.mnemo-cards.online/"
|
|
echo " https://code.mnemo-cards.online/ (same service)"
|
|
echo ""
|
|
echo "🔑 Password: AGktOidxrah1KVC0"
|
|
echo ""
|
|
echo "📝 If you get SSL errors, you may need to obtain certificates:"
|
|
echo " ssh root@$SERVER_IP"
|
|
echo " sudo certbot certonly --standalone -d vscode.mnemo-cards.online -d code.mnemo-cards.online"
|
|
|