vscode server简介 //TODO
安装vscode server 1 curl -fsSL https://code-server.dev/install.sh | sh
直接安装,安装好之后使用code-server就可以直接启动服务了
修改配置文件 ~/.config/code-server/config.yaml 1 2 3 4 bind-addr: 0.0 .0 .0 :8080 auth: password password: 12345679 cert: false
访问方式为 ip:8080
安装screen来实现后台运行
使用screen来新建一个视窗 code(名字随意不要与已有的视窗重复)
在新的视窗里面启动code-server,启动成功之后,使用Ctrl + Alt + D 退出视窗返回主shell窗口。这样code-server就一直在后台运行了。
nginx配置二级域名访问 配置DNS解析 示例域名为 code.exmaple.com
在你的域名DNS解析控制台里面,添加code的A解析到你的服务器ip上。
如下图 【图片】
安装nginx服务
配置nginx服务 修改/etc/nginx/nginx.conf文件,注释掉部分关于80端口的server描述。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 # For more information on configuration, see: # * Official English Documentation: http://nginx.org/en/docs/ # * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; # 从这里开始注释 # server { # listen 80 default_server; # listen [::]:80 default_server; # server_name _; # root /usr/share/nginx/html; # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; # location / { # } # error_page 404 /404.html; # location = /40x.html { # } # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } #} #直到这里解释 # Settings for a TLS enabled server. # # server { # listen 443 ssl http2 default_server; # listen [::]:443 ssl http2 default_server; # server_name _; # root /usr/share/nginx/html; # # ssl_certificate "/etc/pki/nginx/server.crt"; # ssl_certificate_key "/etc/pki/nginx/private/server.key"; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 10m; # ssl_ciphers PROFILE=SYSTEM; # ssl_prefer_server_ciphers on; # # # Load configuration files for the default server block. # include /etc/nginx/default.d/*.conf; # # location / { # } # # error_page 404 /404.html; # location = /40x.html { # } # # error_page 500 502 503 504 /50x.html; # location = /50x.html { # } # } }
添加/etc/nginx/conf.d/code.exmaple.com.conf 配置文件,将code server的8080端口转发到80端口。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 server { listen 80 default_server; listen [::]:80 default_server; server_name code.exmaple.com; #auth_basic "Plz input qibao‘s password"; #auth_basic_user_file "/usr/local/nginx/pass"; location / { #root html; proxy_pass http:// 127.0.0.1:8080; proxy_set_header Host $host; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection upgrade; proxy_set_header Accept-Encoding gzip; # } }
重启nginx服务或者重载nginx配置文件
1 2 systemctl restart nginx nginx -s reload
最后 你就可以同过code.exmaple.com来直接访问你的code server服务了,在登录界面输入配置文件中的密码既可以开始使用code server。