Jul 15, 2024
2024-07-15T14:42:00+05:30
by
Asif Mohammad Mollah
Updated
Jul 5
2025-07-05T13:46:30+05:30
3 min
Purpose of this guide is to provide a step-by-step installation process for Visual Studio Code server on Linux systems. This guide will help you set up VS Code server for remote development in web interface.
Installation Via GitHub releases
- Go to temp directory and create a directory named code-server.
1
2
3
| cd /tmp
mkdir code-server
cd code-server
|
- Download compatible binaries of code server.
1
| wget https://github.com/coder/code-server/releases/download/v4.23.1/code-server-4.23.1-linux-amd64.tar.gz
|
- Extract tarball.
1
| tar -zxvf code-server-4.23.1-linux-amd64.tar.gz
|
- Copy extracted directory to
/usr/lib
and create symblink.
1
2
| sudo cp -r code-server-4.23.1-linux-amd64 /usr/lib/code-server
sudo ln -s /usr/lib/code-server/code-server /usr/bin/code-server
|
- Create a directory to store data:
1
| sudo mkdir /var/lib/code-server
|
- Cleaning up
1
2
| cd /tmp
rm -rf code-server
|
Installation using package manager
- Install
1
2
| wget https://github.com/coder/code-server/releases/download/v4.23.1/code-server_4.23.1_amd64.deb
sudo dpkg -i code-server_4.23.1_amd64.deb
|
- See installation directory
Now create a service to manage it better:
1
| sudo vim /lib/systemd/system/code-server.service
|
Add following code inside this file.
1
2
3
4
5
6
7
8
9
10
11
| [Unit]
Description=code-server
After=nginx.service
[Service]
User=<username>
Type=simple
Environment="<password-of-your-system>" "HOME=<path-of-your-home-dir>" "VSCODE_PROXY_URI=<proxy-port-uri>"
ExecStart=/usr/bin/code-server --bind-addr=0.0.0.0:8080 --user-data-dir /var/lib/code-server "Welcome to VS Code IDE" --auth password --app-name "VS Code IDE" --welcome-text "Welcome to VS Code IDE"
Restart=always
[Install]
WantedBy=multi-user.target
|
Managing service
1
2
3
| sudo systemctl start code-server
# Or
sudo service code-server start
|
1
2
3
| sudo systemctl stop code-server
# Or
sudo service code-server stop
|
1
2
3
| sudo systemctl status code-server
# Or
sudo service code-server status
|
1
| sudo systemctl enable code-server
|
1
| sudo systemctl disable code-server
|
Nginx Config for exposing to outside:
File /etc/nginx/sites-available/code.pvt.one
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
| server {
listen 80;
listen [::]:80;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name code.pvt.one;
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:3535; #change app port
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location ~ /proxy/(\d+)/(.*) {
proxy_pass http://localhost:$1/$2;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
|
Proxy Port based URL will be like this
1
| https://<port>.proxy.example.com
|
1
| https://example.com/proxy/<port>
|
Nginx Configuration
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| # Map the port from the server name to the backend address
map $port $backend {
default 127.0.0.1:$port;
}
# NGINX server block
server {
listen 443 ssl;
server_name ~^(?<port>\d+)\.proxy\.example\.com$;
ssl_certificate /etc/letsencrypt/live/proxy.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/proxy.example.com/privkey.pem;
location / {
# Proxy the request to the backend determined by the server name
proxy_pass http://$backend;
# Forward all headers from client request to backend server
proxy_set_header Host $host;
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;
# Forward all other headers dynamically
proxy_pass_request_headers on;
# It will allow web socket as well
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
| server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name _;
location ~ /proxy/(\d+)/(.*) {
proxy_pass http://localhost:$1/$2;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}
|