Host a website using a tailnet device
This topic provides details about serving a website from a Tailscale device that is only accessible to other users in a Tailscale network (known as a tailnet) using Tailscale Serve. Alternatively, you can use the instructions below to host a website that is accessible to the public Internet, using Tailscale Funnel.
Prerequisites
- You need a Tailscale account.
- You need to install Tailscale on your local machine.
We recommend serving your files and website using a Linux VM. You can attempt this on macOS. However, due to the sandboxed nature of the operating system, you may encounter errors.
Here are instructions for creating various cloud-based Linux VMs and setting up Tailscale on your VM:
After your Linux VM is created, you must also install Tailscale on your Linux VM.
Serve your files and website
-
Start by creating a file named
index.htmlon your local machine for testing. Here is an example of HTML code that you can use in your file:<!DOCTYPE html> <html> <head> <title>Test Website</title> </head> <body> <h1>This is a heading</h1> <p>This is a paragraph</p> </body> </html> -
Create a
/tmpdirectory and a subdirectory on your local machine below the root directory:mkdir /tmp mkdir /tmp/test-funnel -
Move the
index.htmlfile you created into the/tmp/test-funnelsubdirectory that you created in the previous step. In this example, the current location of the file is/home/amelie:mv /home/amelie/index.html /tmp/test-funnel -
Run the following command on your machine to serve the
index.htmlfile to your tailnet:tailscale serve /tmp/test-funnel/index.htmlOr, if you want to make the same files and website visible on the public Internet, use the following command:
tailscale funnel /tmp/test-funnel/index.html
Share your website
You can now share the website URL by combining your tailnet machine name and the name of your tailnet. The machine name can be found in the Machines page of the admin console, and the tailnet DNS name can be found in the DNS page of the admin console.
If your tailnet machine name is amelie-vm, and your tailnet DNS name is pango-lin.ts.net, share the URL:
https://amelie-vm.pango-lin.ts.net
