默认分类,tools 搭建web版vscode编辑器 发表于 2022-05-07 浏览量 437 没有评论 安装包地址:https://github.com/coder/code-server/releases/download/v4.4.0/code-server-4.4.0-linux-amd64.tar.gz # 背景 有时候我们开发东西,没有开发完,需要带电脑回去,这就很麻烦了, 在别的电脑开发,又得配各种环境,有了这个在线的编辑器,就不怕换电脑的麻烦。方便得很,哈哈哈 一定要配置好ssl证书,不然有些东西用不了。 # 安装 ``` wget https://github.com/coder/code-server/releases/download/v4.4.0/code-server-4.4.0-linux-amd64.tar.gz tar xf code-server-4.3.0-linux-amd64.tar.gz cd code-server/ ./code-server # 启动会生成配置文件,/root/.config/code-server/config.yaml # 要修改密码即可关闭服务 cat /root/.config/code-server/config.yaml bind-addr: 127.0.0.1:8081 # 绑定的端口 auth: password password: xxx # 密码 cert: false ``` # 配置后台运行 ``` nohup ./code-server & # 或者使用supervisor cat /etc/supervisord.d/vscode.ini [program:vscode-server] user=root directory = /data/app/code-server/ command = /data/app/code-server/code-server autostart = true autorestart = true stdout_logfile = /data/app/code-server/%(program_name)s.log stderr_logfile = /data/app/code-server/%(program_name)s.err ``` # 配置nginx代理 ``` server { listen 443 ssl; server_name code.ewain.top; access_log /data/log/code.ewain.top/access.log; error_log /data/log/code.ewain.top/error.log; ssl_certificate /etc/nginx/conf.d/ssl_key/code.ewain.top_nginx/code.ewain.top_bundle.pem; ssl_certificate_key /etc/nginx/conf.d/ssl_key/code.ewain.top_nginx/code.ewain.top.key; ssl_session_timeout 5m; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; ssl_prefer_server_ciphers on; # proxy_redirect off; # proxy_set_header Host $host; # proxy_set_header X-Real-IP $remote_addr; # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; if ($host != 'code.ewain.top') { rewrite ^/(.*)$ https://code.ewain.top/$1 permanent; } if ($http_user_agent ~* (Scrapy|Curl|HttpClient)) { return 403; } location / { proxy_pass http://127.0.0.1:8081; proxy_http_version 1.1; proxy_cache_bypass $http_upgrade; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Port $server_port; } } server { listen 80 ; server_name code.ewain.top; access_log /data/log/code.ewain.top/access.log; error_log /data/log/code.ewain.top/error.log; rewrite ^(.*)$ https://$host$1 permanent; } ``` # 配置中文 打开命令面板输入:Configure Display Language 找到中文包,安装即可。