Simple way to expose local development server securely to the Internet

Pritthish Nath
2 min readMar 28, 2024

--

Prerequisites

  1. A Linux cloud server.
  2. A public domain (pointing to the Linux server).

Using a virtual network

Here, we will be using Tailscale free tier service. Tailscale offers Wireguard-based VPN service, in which the network acts like an overlay network, meaning it does not interrupt the current LAN or the underlay network configuration of the connected devices.

Sign up in Tailscale, and add the cloud server, and local PC as machines by installing and activating the Tailscale client app.

Tailscale dashboard

Also, enable MagicDNS from the DNS tab in Tailscale dashboard.

Routing inbound traffic to local PC

We can route the domain traffic by leveraging Caddy’s reverse proxy method with automatic HTTPS. Install the Caddy server in your cloud server. To setup Caddy server check my previous article.

Click on the connected local PC in the Tailscale machines list, and copy the Full Domain from machine details section.

Then, add a reverse proxy configuration in /etc/caddy/Caddyfile pointing to the tailnet domain.

Make sure that 80 and 443 ingress ports are open of the Linux server, and a domain or sub-domain pointing to it.

local.your-domain.com {
reverse_proxy your-pc.tailnet-domain.ts.net:3000
}

Replace the domains and port w.r.t. your configuration, and restart the Caddy server.

Your local site running in the respective port should be live at the sub-domain with HTTPS.

--

--

Pritthish Nath
Pritthish Nath

Written by Pritthish Nath

Web developer based in Kolkata

No responses yet