Home > Article > Development Tools > How to use code-server to build your own cloud VSCode?
Related recommendations: "vscode Basic Tutorial"
Recently, I always have to carry a computer when I go out to study, which is quite tiring, but I A computer is required for programming. Is there any way I can just take my iPad out and program at the same time?
The answer is the open source project code-server, through which VS Code can be run on the browser. Below I will introduce how to use code-server to build your cloud VS Code.
Run VS Code on your server through code-server, and then access VS Code through the browser.
First you need to prepare a server. The minimum configuration recommended by the official documentation is
If you don’t have a server yet, it is recommended to buy Tencent Cloud (Conscience Cloud) server in China; it is recommended to buy Vultr abroad, which is billed by volume and has a good line. Support WeChat/Alipay. If you want to support me, you can use my AFF link and you will get a $100 credit and I will get a $25 credit.
The operating system can use any Linux distribution you like. This article uses Ubuntu 20.04 as an example.
We will install code-server through the official script. Use XShell or Putty to log in to your server, and then run the following commands in sequence:
curl -fsSL https://code-server.dev/install.sh | sh -s -- --dry-run curl -fsSL https://code-server.dev/install.sh | sh
After completion, the installation script will print out how to run and use code-server.
systemctl start code-server@$USER // 启动code-server
code-server uses a password to log in by default (the password is saved in ~/.config/code-server/config.yaml
), and monitors losthost thus avoids exposing itself to the outside world. But our goal is to access it on different machines.
Below I will introduce a safe and simple method to access code-server.
Before going further, you need to ensure that the server opens the HTTP/HTTPS port
ufw allow 80 ufw allow 443
1. A domain name of your own (you have already seen this, I believe you also have a domain name. If you don’t have one yet, you might consider purchasing one (I use NameCheap, the Github student package comes with a free NameCheap domain for one year).
2. Use A records to resolve your domain name to the server IP.
3. Install Caddy.
echo "deb [trusted=yes] https://apt.fury.io/caddy/ /" \ | sudo tee -a /etc/apt/sources.list.d/caddy-fury.list sudo apt update sudo apt install caddy
Caddy server is an open source web server written in Golang that supports HTTP/2. It uses the Golang standard library to provide HTTP functionality. A notable feature of Caddy is that HTTPS is enabled by default. It is the first web server to provide HTTPS features without additional configuration.——Wikipedia
Note: The above method installs Caddy 2, and most of the Caddy documents currently searched on the Chinese Internet are version 1. There are many differences between 2 and 1. Please check it yourself. Official English documentation.
4. nano /etc/caddy/Caddyfile
, replace the content with the following
yourdomain.com reverse_proxy 127.0.0.1:8080
5. Restart caddy:
sudo systemctl reload caddy
Then visit https://<your-domain-name>
in the browser to enter your code-server page!
Just modify the value of password in ~/.config/code-server/config.yaml
, and then restart code-server:
sudo systemctl restart code-server@$USER
code-server Setup Guide(https://github.com/cdr/code-server/blob/v3.7.3/doc/guide.md)
For more programming-related knowledge, please visit: programming teaching! !
The above is the detailed content of How to use code-server to build your own cloud VSCode?. For more information, please follow other related articles on the PHP Chinese website!