Web Based VSCode with code server
i12bretro
#VSCode #BrowserBasedTools #DeveloperTools
Full steps can be found at https://i12bretro.github.io/tutorials/0196.html
Installing code-server
- Log into the Linux device
- Run the following commands in a terminal:
download the code-server install.sh
wget https://code-server.dev/install.shmake it executable
chmod +x ./install.shrun the installer
sudo ./install.sh --prefix=/usr/localstart the service as root
sudo su sudo systemctl enable --now code-server@$USER exitedit the config.yaml
sudo nano /root/.config/code-server/config.yaml - Edit the password, or change the authentication type to none and change the bind-addr to bind-addr: 127.0.0.1:8888
- Continue with the following command in terminal:
restart code-server service
sudo systemctl restart code-server@root.service - Launch on web browser on the host running code-server and navigate to http://DNSorIP:8888
- Browser based VS Code......pretty nice
Out of the box, code-server is only reachable from the host that it is installed on. An easy to configure workaround is to setup a proxy server to allow requests to Apache/NGINX to be routed to code-server.
Apache Proxy Server (optional, but recommended)
- Run the following commands in terminal:
install apache httpd
sudo apt install apache2enable headers, rewrite, proxy and proxy_http modules
sudo a2enmod proxy proxy_http rewrite headers proxy_wstunneledit the default site
sudo nano /etc/apache2/sites-available/000-default.conf - Paste the following configuration into the existing VirtualHost Location /code- RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_URI} !(.)/$ RewriteRule ^(.)$ http://%{HTTP_HOST}/code/ [L,R=301] /Location- Location /code/- Header set X-Frame-Options ALLOWALL RewriteEngine On RewriteCond %{HTTP:Upgrade} =websocket [NC] RewriteRule /(.*) ws://127.0.0.1:8888/$1 [P,L] ProxyPreserveHost on ProxyPass http://127.0.0.1:8888/ ProxyPassReverse http://127.0.0.1:8888/ /Location-
- Press CTRL+O, Enter, CTRL+X to write the changes to code-server.conf
- Continue with the following commands in terminal:
2021-08-15
0.0 LBC
Copyrighted (contact publisher)
23675531 Bytes