Coding on iPad using VSCode, Caddy, and code-server (2024)

Visual Studio Code hasquickly become the text editor many people use for their day-to-day work.Its cross-platform compatibility, speed, and plethora of extensions make it aneasy choice.

Coder.com’s code-server lets you runVSCode on a server and access it on any device, including an iPad. This is anatural pairing for Tailscale, which lets you secure a server, and easilyaccess it from anywhere.

However, code-server isn’t safe to expose over the publicinternet,which usually leads to installing a public-facing ssh proxy or an httpreverse proxy like nginx in front of it. Tailscale eliminates all that,giving you a fast, private connection no matter where you are.

Prerequisites

Before you begin this guide, you’ll need a few things:

  • An iPad or similar tablet, or a laptop to access your VSCode serverremotely. An external keyboard and mouse input willmake writing code easier.

  • A server to host code-server. This guide assumes you’re using an Ubuntu20.04 server, but the steps should be similar for most hosting providersand Ubuntu versions. You can also install code-server on a desktopcomputer or server at home.

  • Lastly, you’ll need a Tailscale account.You can create a free solo account in a few seconds.

Step 1: Install Tailscale on an Ubuntu server

After spinning up a new server, ssh into it with your account details.

ssh <username>@<server host ip>

Then, install Tailscale with a single command:

curl -fsSL https://tailscale.com/install.sh | sh

Alternatively, we provide manual installation instructions.

Once it is installed, and you’ve run tailscale up on your Raspberry Pi, continue to the next step.

Now, let’s confirm everything is working by ssh-ing into the server overTailscale. We’ll exit the machine and re-ssh with our Tailscale IP.

First, find and copy your machine’s Tailscale IP.The easiest way to do this is to run

ip addr show tailscale0

And copy the 100.x.y.z address. Once you’ve found it, exit your sshsession, and start a new one with your newly copied Tailscale IP.

ssh <username>@<copied 100.x.y.z address>

If you’ve enabled MagicDNS on your network, you canuse your server’s MagicDNS hostname instead of the IP address.

Step 2: Install code-server

On your server, run the following one-line command to install code-server.

curl -fsSL https://code-server.dev/install.sh | sh

You can also download pre-built binaries from their GitHub releasespage.

Once the installation is complete, configure code-server to start on boot byrunning the following command:

sudo systemctl enable --now code-server@$USER

code-server is now running on your local machine, on port 8080. Now, we’llexpose this server over Tailscale.

Step 3: Make code-server available on the Tailscale interface

By default, code-server only allows access from the local device(127.0.0.1), and restricts access with a password.

Since we’ll only be accessing code-server over Tailscale, and Tailscalealready uses your existing Single Sign-On (SSO) identity provider, there’sno need for password-based auth —we can already trust that you’reauthorized if you can even access the server!

To do this, we’ll update code-server’s configuration. First, we’ll open upthe config file at ~/.config/code-server/config.yaml

The default config file looks something like this:

bind-addr: 127.0.0.1:8080auth: passwordpassword: <random-password>cert: false

We’ll update the auth field to none and remove the password field, andmake the service available only on your Tailscale IP address.

After these changes, your config file should look like this (don’t forget toreplace <copied 100.x.y.z address> with your Tailscale IP address!):

bind-addr: <copied 100.x.y.z address>:8080auth: nonecert: false

Apply these changes by restarting code server:

sudo systemctl restart code-server@$USER

Step 4: Install Tailscale on your iPad

The last step is to install and sign in to Tailscale on your iPad. You canfind Tailscale in the App Store. Make sureyou log in with the same account as on your server, so the two devices cansee each other.

Once you’re authenticated, you should be able to access your server from theiPad by visiting http://100.x.y.z:8080/. (Make sure to fill in the rightIP address or MagicDNS hostname!)

Step 5: Write code!

You’re done! Access your VSCode instance from anywhere. You can code from acafé near your home or from the other side of the world. It’s all the same.And it’s only accessible over Tailscale.

There are a few caveats to coding on an iPad.

For more configuration options, explore the code-server repository’s FAQdocumentation.

Bonus: use https with Let’s Encrypt

code-server works fine over plain http (over an encrypted+authenticatedTailscale link) but some features will be unavailable. To make it fullyfunctional, you’ll need to set up https.

  1. First, get an automated Tailscale LetsEncryptcertificate.

  2. Then, use that cert by setting up a Caddy- or nginx-based webproxy.

Bonus: additional firewall settings

Since we’ll be developing on this device, chances are it’ll have access tosensitive information: private code, private data, etc. To keep things safe,you may want to restrict all access to the server to only be over Tailscale.

For more details on how to further lock down a server, read our guide onUbuntu and ufw.

Many thanks to Tailscale user Sam Linville, whoseoriginal guideinspired this article.

Coding on iPad using VSCode, Caddy, and code-server (2024)
Top Articles
Latest Posts
Article information

Author: Velia Krajcik

Last Updated:

Views: 5800

Rating: 4.3 / 5 (74 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Velia Krajcik

Birthday: 1996-07-27

Address: 520 Balistreri Mount, South Armand, OR 60528

Phone: +466880739437

Job: Future Retail Associate

Hobby: Polo, Scouting, Worldbuilding, Cosplaying, Photography, Rowing, Nordic skating

Introduction: My name is Velia Krajcik, I am a handsome, clean, lucky, gleaming, magnificent, proud, glorious person who loves writing and wants to share my knowledge and understanding with you.