code-server安装使用,并配置frp反射域名访问
为什么使用
code-server是VSCode网页版开发软件,可以在浏览器访问编程,可以使用vscode中的插件。如果有自己的服务器,使用frp透传后,域名访问在线编程,使用方便,打开的服务端口不需要单独配置,可以直接在原域下访问,使用方便。
安装配置
arm环境下载地址:
# 替换最新版本号(查看 https://github.com/coder/code-server/releases)
VERSION="4.22.0" # 示例版本,请检查最新版
wget https://github.com/coder/code-server/releases/download/v$VERSION/code-server_${VERSION}_arm64.deb
或
wget https://github.com/coder/code-server/releases/download/v$VERSION/code-server_4.22.0_arm64.deb
现在新版地址
wget https://github.com/coder/code-server/releases/download/v4.100.2/code-server_4.100.2_arm64.deb
amd系统下载地址:
wget https://github.com/coder/code-server/releases/download/v4.22.0/code-server_4.22.0_amd64.deb
下载后安装
sudo dpkg -i code-server_4.22.0_amd64.deb
sudo apt install -f # 修复依赖
安装后使用
-- 启动
code-server
-- 密码参考文件内配置,默认只在本机能访问,也可以在配置中更改为0.0.0.0外部访问
nano /root/.config/code-server/config.yaml
-- 我的配置
bind-addr: 0.0.0.0:8080
auth: password
password: xxxx密码
cert: false
插件管理
官方参考手册:Extension Marketplace
离线安装插件,下载后指定本地文件安装
code-server --install-extension /path/to/blockman-highlight.vsix
安装微软官网对vscode的插件
去官网搜索下载,用上面命令安装,或如下插件安装,https://marketplace.visualstudio.com
-- C#插件
扩展中搜索安装vscode-plugin-installer安装后ctrl + shift + p输入命令回车:VS Code Plugin Installer输入对应插件地址,如:https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csdevkit根据提示Enter确认安装,Esc取消
相关插件下载地址
https://github.com/dotnet/vscode-csharp/releases/tag/v1.24.4
NGINX域名解析和FRP透传配置参考我之前在香橙派上网站配置介绍:OrangePi AIpro从上手到网站部署使用_orange pi aipro 远程登录-CSDN博客
由于code-server除了界面透传,还需要进行websocket通讯,所以,还需要在NGINX中添加websocket配置,配置如下
# 在 http{} 块内定义 mapmap $http_upgrade $connection_upgrade {default upgrade;'' close;}server {listen 80;server_name xxx.com;location / {index index.html vnc.html;proxy_pass http://xxxx:6060;}location ~ ^/(websockify|socket) {# 启用调试日志access_log /var/log/nginx/websocket.log;error_log /var/log/nginx/websocket_error.log debug;proxy_pass http://xxx:6060;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade; # 自动填 websocket 或空proxy_set_header Connection $connection_upgrade; # 自动填 upgrade 或 close# 如果后端需要特定 Host 头proxy_set_header Host $host;# 标准代理头(必须!)proxy_set_header Host aipro.missingyou.wang; # 传递客户端请求的域名proxy_set_header X-Real-IP xxxxxx; #$remote_addr; # 客户端真实 IP#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 经过的代理链 IPproxy_set_header X-Forwarded-Proto $scheme; # 协议(http/ws 或 https/wss)# 关键优化:禁用缓冲和超时设置proxy_buffering off;proxy_read_timeout 86400s; # 长连接超时(WebSocket 需要)}}