Setting up your MacBook to run VSCode anywhere using Code-Server

Setting up your MacBook to run VSCode anywhere using Code-Server

Tags
Software Development
Tech
Projects
Web Dev
Published
June 8, 2023
Hey everyone, welcome to my first blog post! I got inspired to write this because I wanted to turn my iPad into a coding machine to try and eliminate having to carry around a 16” laptop everywhere I go for simple web stack dev. In today’s day and age this should be easily achievable, or so I thought 🤔…
Turns out, it is! I just didn’t have a guide on how to do this in a quick manner, until now 👌
Note: I know Github Codespaces exists, I didn’t want to mess around with enabling and disabling the spaces to avoid billing charges

What we’ll cover

  • Installing code-server
  • Getting it up and running as a service
  • Connecting to the server from a remote IP
  • Setting up remote access and an HTTPS connection (Optional, but highly recommended)

Let’s start with the pre-requisites

  • Brew installed on the target server machine 🍺 (you can use code-server’s install script as well, I just love using Brew)
  • Terminal knowledge (If you don’t know what terminal is, you’ve stumbled onto the wrong article 😬)
K, enough chit chat, let’s get to it

Setting up code-server

  1. Install code-server via brew
brew install code-server
2a. Run code-server (If you don’t want to register is an auto start service)
brew services run code-server -v
2b. Register it as a service to auto start (Optional)
brew services start code-server -v
3. Connect to it locally and test it out
  • First, find the server password, this can be found in
~/.config/code-server/config.yaml
  • Connect to your instance via 127.0.0.1:8080
  • Enter the password, marvel at the accomplishment! 🎉
Note: At this point you could remove the password from code-server if you wish, since you need to be authenticated to tailscale in order to access the server but I left mine on for security 🔐

Setting up remote access with HTTPS

  1. Sign up for Tailscale https://tailscale.com/ (No affiliate, just found a free tool that works great!)
  1. Download the app to the server machine (In this case an MBPro)
  1. Download the app for your iPad

Setting up HTTPS

  1. Install caddy
brew install caddy
2. Enable HTTPS on tailscale, please follow steps 1–4 on Tailscale: https://tailscale.com/kb/1153/enabling-https/#configure-https
3. Then run the cert command locally to generate a cert. You’ll need the following:
notion image
Your tailnet name can be found in the DNS settings of the admin console, which can be found here: https://login.tailscale.com/admin/dns
/Applications/Tailscale.app/Contents/MacOS/Tailscale cert <device-name>.<tailnetname>
4. Start caddy as a service
brew services start caddy -v
This will launch the service on login and will display the settings file for the service. We’re looking for the ProgramArguments entry with a string containing a path to the Caddyfile. Mine was located at
/usr/local/etc/Caddyfile
5. Once you have the path to your Caddyfile, create a new Caddyfile at the destination (At the time of writing there was no file present by default)
sudo touch /usr/local/etc/Caddyfile
6. Then edit the file to contain the following:
<device-name>.<tailnetname> reverse_proxy <tailent_device_ip>:8080
7. Restart code-server and caddy
brew services restart caddy && brew services restart code-server
That’s it! You should now be able to connect to your computer remotely and access VSCode on your iPad, happy coding!! 🎉👨‍💻