Code-Server is an online version of VS Code developed by Microsoft, which is a browser-based IDE. There is a browser to write code and related documents online. The biggest advantage should be that the iPad can also become a “productivity tool”. The example here uses Debian 11 amd64 system, non-root account, native environment (not docker). The official requirements are 1G memory and 2-core CPU, the recommended option is 2G memory and 2-core CPU, and the hard disk is 32G SSD. The example here uses a VPS with the specific configuration: 2G memory, 2-core CPU, and 30G SSD.
- Install Code-Server
Microsoft officially provides different installation packages on GitHub (https://github.com/coder/code-server/releases/), but we do not need to download and unpack installation manually, because a one-click installation script is provided:
sudo apt install curl # install curl
curl -fsSL https://code-server.dev/install.sh | sh #Note that this is not the root user
sudo systemctl enable --now code-server@$USER # Let Code-Server start automatically and run in the background, $USER is changed to your current user.
At this point, the Code-Server password is generated in the current user’s configuration file, the specific location is ~/.config/code-server/config.yaml, the general content is as follows:
bind-addr: 127.0.0.1:8080 #Intranet address
auth: password # login method is password
password: fb481f0197e8d9581684dcc4 # password
cert: false # Do not use certificate verification
- Set up SSL and Nginx reverse generation
Since the intranet is opened by default, it is necessary to use Nginx to reverse the generation. Considering the security, the SSL certificate of Let’s Encrypt is used to achieve full https access.
sudo apt update # update it
sudo apt install -y nginx certbot python3-certbot-nginx # Install nginx and Let's Encrypt's certbot to install ssl
Then configure the nginx configuration file
/etc/nginx/sites-available/ # Enter the directory of the configuration file
sudo mv default code-server # Change the default configuration file name to code-server
copy code
Use sudo privileges to edit the code-server file as follows:
server {
listen 80;
listen [::]:80;
server_name code.domain.com;
#Note, code.domain.com is your own URL
location / {
proxy_pass http://localhost:8080/;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
}
}
Then soft link the nginx configuration file and apply for the ssl certificate
sudo rm /etc/nginx/sites-enabled/default # delete old soft links
sudo ln -s /etc/nginx/sites-available/code-server /etc/nginx/sites-enabled/code-server # New soft link
sudo certbot --non-interactive --redirect --agree-tos --nginx -d code.domain.com -m [email protected] # Note that code.domain.com is your domain name, email@example .com for your email
At this point, all the configuration is completed. In theory, the browser can enter the domain name to log in, but it is recommended to use the reboot command to restart the system, otherwise you may encounter problems such as inaccessibility of the page (because nginx has not been restarted).
After the construction is completed, the official language plug-ins and adaptations for Python, golang and rust are installed. The system takes up a total of 5G, and there is still 23G of available space.