当前位置:   article > 正文

code-server 部署vscode在线编辑器

code-server 部署vscode在线编辑器

theme: awesome-green

code-server是一款在线的vscode工具,只要将 code-server 部署到自己的服务器之后,就可以通过浏览器使用vscode,很好的解决了远程编辑服务器中文件的问题,方便好用。

code-server的地址为: https://github.com/cdr/code-server

准备

准备一台linux机器
安装docker:https://docs.docker.com/install/linux/docker-ce/centos/
如果要反向代理,安装nginx

安装

```bash

在linux上创建一个目录,用来存放编辑器可以访问的文件例如:

mkdir -p /usr/local/codefolder

修改文件夹的权限,否则无法创建和修改文件

chmod -R 777 /usr/local/codefolder

安装

docker run --name codeserver -d -p 8443:8443 -v "/usr/local/codefolder:/home/coder/project" codercom/code-server --allow-http --no-auth ```

浏览器访问http://localhost:8443

参数配置详情

``` sage: code-server [options]

Run VS Code on a remote server.

Options: -V, --version output the version number --cert --cert-key -e, --extensions-dir

Override the main default path for user extensions. --extra-extensions-dir [dir] Path to an extra user extension directory (repeatable). (default: []) --extra-builtin-extensions-dir [dir] Path to an extra built-in extension directory (repeatable). (default: []) -d, --user-data-dir Specifies the directory that user data is kept in, useful when running as root. -h, --host Customize the hostname. (default: "0.0.0.0") -o, --open Open in the browser on startup. -p, --port Port to bind on. (default: 8443) -N, --no-auth Start without requiring authentication. -H, --allow-http Allow http connections. --disable-telemetry Disables ALL telemetry. --socket Listen on a UNIX socket. Host and port will be ignored when set. --trust-proxy Trust the X-Forwarded-For header, useful when using a reverse proxy. --install-extension Install an extension by its ID. -h, --help output usage information ```

Nginx反向代理

```

user nobody;

worker_processes 2;

error_log logs/error.log;

error_log logs/error.log notice;

error_log logs/error.log info;

pid logs/nginx.pid;

events { worker_connections 1024; }

http { include mime.types; default_type application/octet-stream;

  1. #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  2. # '$status $body_bytes_sent "$http_referer" '
  3. # '"$http_user_agent" "$http_x_forwarded_for"';
  4. #access_log logs/access.log main;
  5. sendfile on;
  6. #tcp_nopush on;
  7. client_max_body_size 200m;
  8. #gzip on;
  9. map $http_upgrade $connection_upgrade {
  10. default upgrade;
  11. '' close;
  12. }
  13. upstream websocket {
  14. server localhost:8443;
  15. }
  16. server {
  17. listen 80;
  18. server_name localhost;
  19. #charset koi8-r;
  20. #access_log logs/host.access.log main;
  21. location / {
  22. proxy_pass http://websocket;
  23. proxy_http_version 1.1;
  24. proxy_set_header Upgrade $http_upgrade;
  25. proxy_set_header Connection "Upgrade";
  26. }
  27. }

} ```

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

闽ICP备14008679号