当前位置:   article > 正文

安装配置code-server使用https_code-server 启动后的访问地址

code-server 启动后的访问地址

在自己的服务器上安装了code-server,但是markdown预览和jupyter都无法正常显示。
查了一下,需要在https加密模式下才能在浏览器中正常使用功能。
自己的服务器是用zerotier在虚拟局域网内连接,没有公网ip和域名,
最后用的是本地签名证书。如果有自己的域名以及DNS,可以参考官方教程用NGINX配置


I 安装

软件地址:https://github.com/coder/code-server/releases

用wget下载压缩文件后用 tar -xzvf解压文件,或下载deb文件后用dkpg安装。

II 启动

进入解压文件夹,启动命令:

./code-server --bind-addr 0.0.0.0:8888
  • 1

./code-server --port 8888 --host 0.0.0.0 --auth password
  • 1

先运行一次,然后修改配置文件

改动:vim ~/.config/code-server/config.yaml
查看:cat ~/.config/code-server/config.yaml
然后在同一局域网下访问host地址,输入密码即可。
后台运行:nohup ./code-server >> log.log 2>&1 &
查看运行的后台进程:ps -aux|grep chat.js

a:显示所有程序
u:以用户为主的格式来显示
x:显示所有程序,不以终端机来区分

查看使用某端口的进程:lsof -i:8090
netstat -ap|grep 8090
查看到进程id之后,使用netstat命令查看其占用的端口 netstat -nap|grep [端口号]
终止后台运行的进程:kill -9 进程号

修改密码:

export PASSWORD=“123456” && ./code-server --port 8080 --host 0.0.0.0
  • 1

III 配置https

下载证书制作软件mkcert,并将程序加载到服务器上

为对应网址生成证书

# $ mkcert [website addr]  10.144.0.1为服务器的内网网址
# -cert-file [filename] 生成对应crt文件
# -cert-key [filename] 生成对应key
$ mkcert 10.144.0.1 127.0.0.1 -
  • 1
  • 2
  • 3
  • 4
# 生成证书
$ mkcert -cert-file phone-code-server.crt -key-file phone-code-server.key 10.144.0.1 127.0.0.1
Note: the local CA is not installed in the system trust store.
Note: the local CA is not installed in the Firefox and/or Chrome/Chromium trust store.
Run "mkcert -install" for certificates to be trusted automatically ⚠️

Created a new certificate valid for the following names 
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/153363
推荐阅读
相关标签