5 KiB
5 KiB
VSCode Server Setup Guide
Problem
After server reboot, VSCode Server (code-server) was not accessible:
- https://vscode.mnemo-cards.online/ - not working
- https://code.mnemo-cards.online/ - not working
Root Causes Identified
-
code-server was not configured to start on boot
- Service existed but wasn't properly enabled
- Configuration file had wrong port (8080 instead of 8443)
-
nginx configuration was missing
- VSCode nginx config wasn't deployed to the server
- nginx was trying to use IPv6 (::1) instead of IPv4 (127.0.0.1)
-
Domain conflict
- Both
code.mnemo-cards.onlineandvscode.mnemo-cards.onlinewere initially configured for VSCode - But
code.mnemo-cards.onlineis actually used by Forgejo (git server)
- Both
Solution
Correct Domain Mapping
- https://vscode.mnemo-cards.online/ → VSCode Server (code-server on port 8443)
- https://code.mnemo-cards.online/ → Forgejo Git Server (port 3000)
Fixed Components
1. code-server Service
Created proper systemd service at /etc/systemd/system/code-server.service:
[Unit]
Description=code-server
After=network.target
[Service]
Type=simple
Environment=PASSWORD=AGktOidxrah1KVC0
ExecStart=/usr/bin/code-server --bind-addr 127.0.0.1:8443 --auth password
WorkingDirectory=/root
Restart=always
RestartSec=10
User=root
[Install]
WantedBy=multi-user.target
Configuration at /root/.config/code-server/config.yaml:
bind-addr: 127.0.0.1:8443
auth: password
password: AGktOidxrah1KVC0
cert: false
2. nginx Configuration
Deployed proper nginx configuration for vscode.mnemo-cards.online:
- Location:
/etc/nginx/sites-available/vscode.mnemo-cards.online - Proxy: http://127.0.0.1:8443 (using IPv4, not localhost which resolves to IPv6)
- SSL: Let's Encrypt certificates
- Rate limiting: Configured for login and general access
- WebSocket support: Enabled for VSCode
Deployment Scripts
Created the following scripts in tools/deploy/:
- fix-vscode-server.sh - Diagnoses and fixes code-server installation and configuration
- check-nginx.sh - Checks nginx status and reloads configuration
- deploy-vscode-nginx.sh - Deploys VSCode nginx configuration to server
- fix-nginx-duplicates.sh - Removes duplicate nginx configurations
- test-vscode-from-server.sh - Tests VSCode connectivity from server
- test-vscode-final.sh - Final tests of both URLs
How to Use
Quick Fix After Server Reboot
If VSCode Server is not accessible after server reboot, run:
cd /Users/dmitry/StudioProjects/mnemo_cards/tools/deploy
./fix-vscode-server.sh
Deploy nginx Configuration
To deploy or update nginx configuration:
cd /Users/dmitry/StudioProjects/mnemo_cards/tools/deploy
./deploy-vscode-nginx.sh
Test Connectivity
To test if everything is working:
cd /Users/dmitry/StudioProjects/mnemo_cards/tools/deploy
./test-vscode-final.sh
Access Information
- URL: https://vscode.mnemo-cards.online/
- Username: (no username required, password only)
- Password: AGktOidxrah1KVC0
Service Management
Check Status
ssh root@147.45.152.129
systemctl status code-server
View Logs
ssh root@147.45.152.129
journalctl -u code-server -f
Restart Service
ssh root@147.45.152.129
systemctl restart code-server
Check nginx Status
ssh root@147.45.152.129
systemctl status nginx
nginx -t # Test configuration
Troubleshooting
VSCode Server Not Starting
- Check if service is running:
systemctl status code-server - Check logs:
journalctl -u code-server -n 50 - Verify port is listening:
ss -tuln | grep 8443 - Run fix script:
./fix-vscode-server.sh
nginx 502 Bad Gateway
- Verify code-server is running on port 8443
- Check nginx error logs:
tail -f /var/log/nginx/error.log - Verify proxy_pass uses 127.0.0.1:8443 (not localhost)
SSL Certificate Issues
Certificates are managed by Let's Encrypt and stored at:
/etc/letsencrypt/live/vscode.mnemo-cards.online/
To renew certificates:
ssh root@147.45.152.129
certbot renew
systemctl reload nginx
Architecture
Internet
↓
nginx (port 443) - SSL termination
↓
code-server (127.0.0.1:8443) - VSCode Server
↓
/root/ - Working directory
Notes
- code-server runs as root user (WorkingDirectory=/root)
- Authentication is enabled with password
- WebSocket support is enabled for VSCode features
- Rate limiting is configured to prevent abuse
- Automatic restart is configured (Restart=always)
- Service is enabled to start on boot (enabled via systemctl)
Recent Changes (2025-11-19)
- ✅ Fixed code-server service configuration
- ✅ Deployed nginx configuration
- ✅ Fixed IPv6/IPv4 issue (localhost → 127.0.0.1)
- ✅ Resolved domain conflict (removed code.mnemo-cards.online from VSCode config)
- ✅ Enabled service auto-start on boot
- ✅ Verified both URLs are working
Status
🟢 OPERATIONAL
- vscode.mnemo-cards.online - Working ✅
- code.mnemo-cards.online - Working ✅ (Forgejo)