Code-Server VS Code in Browser Installation
Code-server brings VS Code to the browser, letting you run a full remote IDE on your Linux VPS or baremetal server. This guide covers installing code-server, configuring Nginx as a reverse proxy with SSL, setting up authentication, and deploying via Docker.
Prerequisites
- Ubuntu 20.04+/Debian 11+ or CentOS 8+/Rocky Linux 8+
- A domain name pointing to your server
sudoor root access- Nginx installed
- At least 1 GB RAM (2 GB recommended)
Installing Code-Server
The official install script handles everything automatically:
# Download and run the install script
curl -fsSL https://code-server.dev/install.sh | sh
# Verify installation
code-server --version
Alternatively, install manually from the GitHub releases:
# Get the latest version
VERSION=$(curl -s https://api.github.com/repos/coder/code-server/releases/latest \
| grep '"tag_name"' | cut -d'"' -f4 | sed 's/v//')
# Download for Ubuntu/Debian
wget "https://github.com/coder/code-server/releases/download/v${VERSION}/code-server_${VERSION}_amd64.deb"
sudo dpkg -i "code-server_${VERSION}_amd64.deb"
For CentOS/Rocky:
wget "https://github.com/coder/code-server/releases/download/v${VERSION}/code-server-${VERSION}-amd64.rpm"
sudo rpm -i "code-server-${VERSION}-amd64.rpm"
Initial Configuration
Code-server's config file is at ~/.config/code-server/config.yaml:
# Start once to generate the default config
code-server &
sleep 2
kill %1
# View and edit the config
cat ~/.config/code-server/config.yaml
Edit the configuration:
# ~/.config/code-server/config.yaml
bind-addr: 127.0.0.1:8080 # Bind to localhost only (Nginx will proxy)
auth: password
password: your_strong_password_here
cert: false # Let Nginx handle TLS
Generate a hashed password instead of plaintext:
# Create a bcrypt-hashed password
echo -n "your_password" | npx argon2-cli -e
# Or use the built-in method:
code-server --config ~/.config/code-server/config.yaml &
cat ~/.config/code-server/config.yaml | grep password
Running as a Systemd Service
# Enable and start the user-level service
sudo systemctl enable --now code-server@$USER
# Check status
systemctl status code-server@$USER
# View logs
journalctl -u code-server@$USER -f
To run code-server system-wide (for a dedicated user):
sudo useradd -m -s /bin/bash codeuser
sudo -u codeuser mkdir -p /home/codeuser/.config/code-server
sudo tee /home/codeuser/.config/code-server/config.yaml << 'EOF'
bind-addr: 127.0.0.1:8080
auth: password
password: change_this_password
cert: false
EOF
sudo systemctl enable --now code-server@codeuser
Nginx Reverse Proxy Setup
sudo nano /etc/nginx/sites-available/code-server
server {
listen 80;
server_name code.yourdomain.com;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# Required for WebSocket support
proxy_http_version 1.1;
proxy_read_timeout 86400;
}
}
sudo ln -s /etc/nginx/sites-available/code-server /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx
SSL Certificate with Let's Encrypt
sudo apt install -y certbot python3-certbot-nginx
sudo certbot --nginx -d code.yourdomain.com \
--non-interactive --agree-tos -m [email protected]
# Verify auto-renewal
sudo certbot renew --dry-run
After certbot, your Nginx config will be updated automatically with SSL.
Docker Deployment
# docker-compose.yml
version: '3.8'
services:
code-server:
image: lscr.io/linuxserver/code-server:latest
container_name: code-server
environment:
- PUID=1000
- PGID=1000
- TZ=America/New_York
- PASSWORD=your_password
- SUDO_PASSWORD=your_sudo_password
- DEFAULT_WORKSPACE=/config/workspace
volumes:
- ./config:/config
- ./workspace:/config/workspace
ports:
- "127.0.0.1:8080:8443"
restart: unless-stopped
docker compose up -d
docker compose logs -f code-server
Managing Extensions
Install extensions from the command line or the VS Code marketplace UI inside the browser:
# Install extensions via CLI
code-server --install-extension ms-python.python
code-server --install-extension esbenp.prettier-vscode
code-server --install-extension golang.go
# List installed extensions
code-server --list-extensions
# Install from a .vsix file
code-server --install-extension /path/to/extension.vsix
Note: The Open VSX registry is used by default instead of the Microsoft marketplace. For Microsoft extensions, download .vsix files directly from the VS Code marketplace.
Troubleshooting
WebSocket connection fails (terminal or live share not working):
Check that Nginx has the Upgrade and Connection headers set correctly, and that proxy_http_version 1.1 is present in your config.
Page loads but shows "Unauthorized":
# Check the password in the config file
cat ~/.config/code-server/config.yaml
# Restart the service after config changes
sudo systemctl restart code-server@$USER
Port already in use:
# Find what's using port 8080
sudo ss -tlnp | grep 8080
# Change bind-addr port in config.yaml and restart
Extensions not installing:
# Check connectivity from the server
curl -I https://open-vsx.org
# For offline environments, download .vsix files and install manually
High memory usage:
Code-server can use significant RAM with many extensions. Limit with systemd:
sudo systemctl edit code-server@$USER
# Add:
# [Service]
# MemoryLimit=1G
Conclusion
Code-server transforms any Linux server into a remote development environment accessible from any browser. With Nginx handling SSL termination and authentication protecting your IDE, you get a secure, full-featured VS Code experience without installing anything on client machines. This setup works especially well on powerful VPS instances for compute-intensive development tasks.


