下载

# 下载地址
https://github.com/coder/code-server/releases/
# 文件名
coder_{VERSION}_linux_amd64.deb

安装

# 安装
sudo dpkg -i code-server_${VERSION}_amd64.deb
# 初始化
sudo systemctl enable --now code-server@$USER
# 重启
sudo systemctl restart code-server@$USER

配置

# sudo su
# vim ~/.config/code-server/config.yaml
# 配置完记得重启软件

bind-addr: "127.0.0.1:8080"
auth: password
password: "this_is_password"
cert: false

绑定域名

  1. 宝塔新建站点,设置域名,选择纯静态

  2. 设置反向代理 http://127.0.0.1:8080

  3. 编辑反向代理配置文件

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;
  }