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

We recommend serving your files and website using a Linux VM. You can attempt this in 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

  1. Start by creating a file named index.html on 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>
    
  2. Create a /tmp directory and a subdirectory on your local machine below the root directory:

    mkdir /tmp
    mkdir /tmp/test-funnel
    
  3. Move the index.html file you created into the /tmp/test-funnel subdirectory 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
    
  4. Run the following command on your machine to serve the index.html file to your tailnet:

    tailscale serve /tmp/test-funnel/index.html
    

    Or, 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 name can be found in the DNS page of the admin console.

If your tailnet machine name is amelie-vm, and your tailnet name is pango-lin.ts.net, share the URL:

https://amelie-vm.pango-lin.ts.net

Want to see this working in action?