1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <!DOCTYPE html>
- <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <title>Web Based VSCode with code-server</title>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- <meta charset="UTF-8">
- <meta name="keywords" content="VSCode,Code Server,Debian,HowTo,GitHub,Browser,Tool,Development,Developer,PHP,Proxy,Apache2,Tutorial,i12bretro">
- <meta name="author" content="i12bretro">
- <meta name="description" content="Web Based VSCode with code-server">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="revised" content="05/23/2022 09:03:11 PM" />
- <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
- <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
- <script type="text/javascript" src="includes/js/steps.js"></script>
- <link href="css/steps.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <div id="gridContainer">
- <div class="topMargin"></div>
- <div id="listName" class="topMargin">
- <h1>Web Based VSCode with code-server</h1>
- </div>
- <div></div>
- <div id="content">
- <h2>Installing code-server</h2>
- <ol>
- <li>Log into the Linux device</li>
- <li>Run the following commands in a terminal:
- <div class="codeBlock"># download the code-server install.sh<br />
- wget https://code-server.dev/install.sh<br />
- # make it executable<br />
- chmod +x ./install.sh<br />
- # run the installer<br />
- sudo ./install.sh --prefix=/usr/local<br />
- # start the service as root<br />
- sudo su<br />
- sudo systemctl enable --now code-server@$USER<br />
- exit<br />
- # edit the config.yaml<br />
- sudo nano /root/.config/code-server/config.yaml</div>
- </li>
- <li>Edit the password, or change the authentication type to none and change the bind-addr to bind-addr: 127.0.0.1:8888</li>
- <li>Continue with the following command in terminal:
- <div class="codeBlock"># restart code-server service<br />
- sudo systemctl restart code-server@root.service</div>
- </li>
- <li>Launch on web browser on the host running code-server and navigate to http://DNSorIP:8888</li>
- <li>Browser based VS Code......pretty nice</li>
- </ol>
- <p>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.</p>
- <h2>Apache Proxy Server (optional, but recommended)</h2>
- <ol>
- <li>Run the following commands in terminal:
- <div class="codeBlock"># install apache httpd<br />
- sudo apt install apache2<br />
- # enable headers, rewrite, proxy and proxy_http modules<br />
- sudo a2enmod proxy proxy_http rewrite headers proxy_wstunnel<br />
- # edit the default site<br />
- sudo nano /etc/apache2/sites-available/000-default.conf</div>
- </li>
- <li>Paste the following configuration into the existing VirtualHost
- <p><location /code><br />
- RewriteEngine On<br />
- RewriteCond %{REQUEST_FILENAME} !-f<br />
- RewriteCond %{REQUEST_URI} !(.*)/$<br />
- RewriteRule ^(.*)$ http://%{HTTP_HOST}/code/ [L,R=301]<br />
- </location><br />
- <br />
- <location /code/><br />
- Header set X-Frame-Options ALLOWALL<br />
- RewriteEngine On<br />
- RewriteCond %{HTTP:Upgrade} =websocket [NC]<br />
- RewriteRule /(.*) ws://127.0.0.1:8888/$1 [P,L]<br />
- ProxyPreserveHost on<br />
- ProxyPass http://127.0.0.1:8888/<br />
- ProxyPassReverse http://127.0.0.1:8888/<br />
- </location></p>
- </li>
- <li>Press CTRL+O, Enter, CTRL+X to write the changes to code-server.conf</li>
- <li>Continue with the following commands in terminal:
- <div class="codeBlock"># restart the apache service<br />
- sudo systemctl restart apache2</div>
- </li>
- <li>Back in the web browser, navigate to http://DNSorIP/vscode</li>
- <li>Enjoy your web based VS Code</li>
- </ol>
- <p>Source: <a href="https://github.com/cdr/code-server" target="_blank">https://github.com/cdr/code-server</a><br />
- Proxy resource: <a href="https://github.com/cdr/code-server/issues/282" target="_blank">https://github.com/cdr/code-server/issues/282</a></p>
- </div>
- </div>
- </body>
- </html>
-
|