#!/bin/bash # Script to test VSCode server from the server itself set -e SERVER_IP="147.45.152.129" SERVER_USER="root" echo "๐Ÿงช Testing VSCode server from the server itself..." echo "" ssh "$SERVER_USER@$SERVER_IP" << 'ENDSSH' set -e echo "๐Ÿ“Š Step 1: Checking if nginx is listening on port 443..." ss -tuln | grep ':443' || echo "โš ๏ธ Nothing listening on port 443" echo "" echo "๐Ÿ“Š Step 2: Checking if code-server is listening on port 8443..." ss -tuln | grep ':8443' || echo "โš ๏ธ Nothing listening on port 8443" echo "" echo "๐Ÿ“Š Step 3: Testing local connection to code-server..." curl -I http://127.0.0.1:8443 2>&1 | head -10 echo "" echo "๐Ÿ“Š Step 4: Testing nginx proxy to code-server (HTTP)..." curl -I -H "Host: vscode.mnemo-cards.online" http://127.0.0.1 2>&1 | head -10 echo "" echo "๐Ÿ“Š Step 5: Testing HTTPS connection locally..." curl -I -k https://127.0.0.1 -H "Host: vscode.mnemo-cards.online" 2>&1 | head -10 echo "" echo "๐Ÿ“Š Step 6: Checking SSL certificates..." if [ -d "/etc/letsencrypt/live/vscode.mnemo-cards.online" ]; then echo "โœ… Certificate directory exists" ls -la /etc/letsencrypt/live/vscode.mnemo-cards.online/ echo "" echo "Certificate details:" openssl x509 -in /etc/letsencrypt/live/vscode.mnemo-cards.online/fullchain.pem -noout -text | grep -A2 "Subject:" openssl x509 -in /etc/letsencrypt/live/vscode.mnemo-cards.online/fullchain.pem -noout -text | grep -A2 "Not After" else echo "โŒ Certificate directory not found" fi echo "" echo "๐Ÿ“Š Step 7: Checking nginx error logs..." echo "Last 20 lines of nginx error log:" tail -20 /var/log/nginx/error.log echo "" echo "๐Ÿ“Š Step 8: Checking firewall status..." if command -v ufw &> /dev/null; then echo "UFW status:" ufw status else echo "UFW not installed" fi echo "" echo "๐Ÿ“Š Step 9: Checking iptables..." iptables -L -n | grep -E "(443|REJECT|DROP)" || echo "No blocking rules found for port 443" echo "" echo "๐Ÿ“Š Step 10: Testing external connection..." echo "Attempting to connect to vscode.mnemo-cards.online from the server..." curl -I https://vscode.mnemo-cards.online 2>&1 | head -10 ENDSSH echo "" echo "โœ… Test complete!"