Skip to content

Commit 296d194

Browse files
atj4merfay
andauthored
blog: Tailscale for DDEV: Simple and Secure Project Sharing (#423)
Co-authored-by: Randy Fay <randy@randyfay.com>
1 parent 3267692 commit 296d194

File tree

3 files changed

+289
-0
lines changed

3 files changed

+289
-0
lines changed
Lines changed: 149 additions & 0 deletions
Loading
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
name: Ajith Thampi Joseph
3+
firstName: Ajith
4+
avatarUrl: https://gravatar.com/avatar/3381b988b59552300f08ff9f6d8918f2?s=128
5+
---
6+
7+
[Ajith](https://www.linkedin.com/in/thampiajit) is a Software Engineer specializing in PHP-based applications (WordPress, Drupal, Laravel) and modern frontend technologies (React, TypeScript). He has extensive experience with Linux web servers, Docker, CI/CD pipelines, and DevOps practices across multiple Git platforms. His work focuses on creating developer tools that eliminate workflow friction and improve team collaboration efficiency.
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
---
2+
title: "Tailscale for DDEV: Simple and Secure Project Sharing"
3+
pubDate: 2025-09-09
4+
summary: "Tired of temporary sharing links? Learn how to use the ddev-tailscale-router add-on to get a stable, secure, and private URL for your DDEV projects."
5+
author: Ajith Thampi Joseph
6+
featureImage:
7+
src: /img/blog/2025/08/ddev_tailscale_flowchart.svg
8+
alt: "DDEV Tailscale Router Cover Image"
9+
caption: "The ddev-tailscale-router add-on enables cross-device testing, stable webhook URLs, and team collaboration."
10+
credit: "Image by Claude AI :)"
11+
categories:
12+
- Guides
13+
- TechNotes
14+
---
15+
16+
I've found that DDEV's [`ddev share`](https://docs.ddev.com/en/stable/users/topics/sharing/) command is a great way to quickly share my local development environment. However, since it uses ngrok, it generates a new, random URL every time unless you use a [stable domain](https://docs.ddev.com/en/stable/users/topics/sharing/#setting-up-a-stable-ngrok-domain). As an alternative, I've created the [`ddev-tailscale-router`](https://github.com/atj4me/ddev-tailscale-router) add-on.
17+
18+
This add-on uses [Tailscale](https://tailscale.com/), a VPN service that creates a private and secure network between your devices. It is free for personal use!
19+
20+
As a result, you get a stable, human-readable URL for each of your DDEV projects, which you can access from any device on your Tailscale network.
21+
22+
I've found this approach to be particularly useful for:
23+
24+
- **Cross-device testing:** I can easily test my sites on my phone or tablet without being on the same Wi-Fi network.
25+
- **Stable webhook URLs:** I can use the permanent Tailscale URL as a reliable endpoint for webhooks, such as those from payment gateways.
26+
- **Team collaboration:** I can share my development environment with team members so they can see my work in progress.
27+
28+
### How it Works
29+
30+
The `ddev-tailscale-router` add-on works by running a Tailscale container alongside your DDEV project. This container automatically connects to your Tailscale network and securely proxies requests to your project's web container.
31+
32+
### Prerequisites
33+
34+
Before installing the add-on, you need to set up Tailscale:
35+
36+
1. **Install Tailscale** on at least two devices (phone, tablet, or computer) by following the [installation guide](https://tailscale.com/download). This is required to generate an auth key.
37+
2. **Enable HTTPS** by following the [Tailscale HTTPS documentation](https://tailscale.com/kb/1153/enabling-https). This is required for TLS certificate generation.
38+
3. **Generate an auth key** by following the [Tailscale auth keys documentation](https://tailscale.com/kb/1085/auth-keys). Ephemeral, reusable keys are recommended.
39+
40+
### Installation
41+
42+
To get started, follow these steps:
43+
44+
1. First, **set up your auth key** (recommended approach):
45+
Add the auth key to your shell environment:
46+
47+
```bash
48+
echo 'export TS_AUTHKEY=tskey-auth-your-key-here' >> ~/.bashrc
49+
source ~/.bashrc
50+
```
51+
52+
Replace `~/.bashrc` with `~/.zshrc` if you use Zsh, or your relevant shell configuration file.
53+
54+
Alternatively, you can set it per project (**NOT RECOMMENDED**, because `.ddev/.env.tailscale-router` is not intended to store secrets):
55+
56+
```bash
57+
ddev dotenv set .ddev/.env.tailscale-router --ts-authkey=tskey-auth-your-key-here
58+
```
59+
60+
2. Next, **install the add-on:**
61+
62+
```bash
63+
ddev add-on get atj4me/ddev-tailscale-router
64+
```
65+
66+
3. Finally, **restart DDEV:**
67+
```bash
68+
ddev restart
69+
```
70+
71+
### Using Your Tailscale URL
72+
73+
Once installation is complete, you can access your project using these commands:
74+
75+
Launch your project's Tailscale URL in browser:
76+
77+
```bash
78+
ddev tailscale launch
79+
```
80+
81+
Get your project's Tailscale URL:
82+
83+
```bash
84+
ddev tailscale url
85+
```
86+
87+
Your project's permanent Tailscale URL will look like: `https://<project-name>.<your-tailnet>.ts.net`. You can also find it in your Tailscale admin console.
88+
89+
### Public vs. Private Mode
90+
91+
The add-on offers two modes for sharing your project:
92+
93+
- **Private (default):** Your project is only accessible to devices on your Tailscale network.
94+
- **Public:** Your project is accessible to anyone on the internet.
95+
96+
To switch between modes:
97+
98+
Switch to public mode (accessible to anyone on the internet):
99+
100+
```bash
101+
ddev dotenv set .ddev/.env.tailscale-router --ts-privacy=public
102+
ddev restart
103+
```
104+
105+
Switch back to private mode (default):
106+
107+
```bash
108+
ddev dotenv set .ddev/.env.tailscale-router --ts-privacy=private
109+
ddev restart
110+
```
111+
112+
> **Note:** For public access, you need to configure your [Access Control List (ACL)](https://tailscale.com/kb/1223/funnel#funnel-node-attribute) to enable Funnel. See the [Tailscale Funnel documentation](https://tailscale.com/kb/1223/funnel) for details on setting up the required ACL policy.
113+
114+
I hope this add-on helps streamline your development workflow! If you run into any issues or have suggestions for improvements, feel free to open an issue on the [GitHub repository](https://github.com/atj4me/ddev-tailscale-router/issues).
115+
116+
### Additional Resources
117+
118+
Here are some additional resources that you might find helpful:
119+
120+
- **[Tailscale](https://tailscale.com/)**: A VPN service that creates a private and secure network between your devices.
121+
- **[Tailscale Download](https://tailscale.com/download)**: Installation guide for Tailscale on various platforms.
122+
- **[Tailscale: Enabling HTTPS](https://tailscale.com/kb/1153/enabling-https)**: Official documentation on enabling HTTPS for TLS certificate generation.
123+
- **[Tailscale Auth Keys](https://tailscale.com/kb/1085/auth-keys)**: Detailed information about creating and managing auth keys.
124+
- **[Tailscale Funnel](https://tailscale.com/kb/1223/funnel)**: Documentation on enabling public access to your Tailscale services.
125+
- **[Tailscale DNS](https://tailscale.com/kb/1054/dns)**: DNS in Tailscale
126+
- **[DDEV dotenv](https://ddev.readthedocs.io/en/latest/users/usage/commands/#dotenv)**: Documentation on managing environment variables with DDEV.
127+
- **[DDEV Docs: Sharing](https://ddev.readthedocs.io/en/latest/users/usage/sharing/)**: The official DDEV documentation on how to share your projects.
128+
- **Medium: [My Journey with PHP Dev Environments](https://medium.com/@josephajithampi/my-journey-with-php-dev-environments-1da9f2806ee9)**: A blog post on setting up a PHP development environment.
129+
- **LinkedIn: [The Day My Development Environment Nearly Broke Me](https://www.linkedin.com/pulse/day-my-development-environment-nearly-broke-me-how-i-thampi-joseph-ildhc/)**: An article on the importance of a reliable development environment.
130+
131+
---
132+
133+
_This blog post was written with the assistance of Amazon Q and Google Gemini. I used them to help simplify the language, improve the flow, and proofread the text._

0 commit comments

Comments
 (0)