iTranslated by AI
Redundant Configuration for Tailscale Funnel with CloudFront Origin Failover
Hi, I'm takipone.
In the following article, I introduced how to publish a web server to the internet using CloudFront and Tailscale Funnel. Since I had two home servers (Brume 2) on hand, in this blog post, I'll show how I set up a redundant configuration using CloudFront's high availability features.
Overview of Redundant Configuration
Tailscale Funnel is a feature for publishing to the internet that leverages the Tailscale VPN. Currently, the hostname of the VPN node directly becomes the endpoint, so there are no abstraction features like virtual IP addresses or aliases, making it difficult to set up server redundancy using Tailscale Funnel alone. By placing CloudFront in front, you not only get custom domains and a CDN but also the origin failover feature, which enables a highly available configuration that switches from Main during normal operation to Replica during an anomaly, as shown below.
Configuring CloudFront Origin Failover
The configuration for origin failover in CloudFront is simple. From the [Origins] tab of your existing CloudFront distribution settings, add origins for both main and replica.


Next, from [Origin Groups] - [Create origin group] at the bottom of the [Origins] tab, register the two origins mentioned above, set main as the primary, and specify the failover conditions to create the group. In this case, assuming a failure of the server process on the home server, I selected 5xx responses as the failover criteria.

Finally, just select the origin group you just created in the behavior's origin selection.

This completes the CloudFront setup.
Casual Data Replication with Taildrop
I casually implemented data replication between the Main and Replica nodes using Tailscale's file transfer feature, Taildrop. Taildrop is a feature for easily transferring files between Tailscale VPN nodes. As the name suggests, it is modeled after AirDrop and is primarily intended for file sharing on desktop and mobile apps.
On Linux, it can be used simply with a send command from the source and a receive command on the destination, so I tried using it by registering it as a cron job this time.
0 */2 * * * tar zcf /hogehoge.tgz /opt/hogehoge && tailscale file cp /hogehoge.tgz replica:
5 */2 * * * rm /hogehoge.tgz; cd /; tailscale file get . && tar zxf /hogehoge.tgz && cd /opt/hogehoge/ && docker-compose restart
Since I do not perform updates from replica to main, the policy is to always perform data updates for Ghost on the main server. In CloudFront, since state-changing HTTP requests are always directed to the primary origin (main), this setup worked without any issues.
CloudFront fails over to the secondary origin only when the HTTP method of the viewer request is GET, HEAD, or OPTIONS. CloudFront does not fail over when the viewer sends a different HTTP method (for example, POST, PUT, etc.).
Additionally, Tailscale's path selection for node-to-node communication is excellent. When I cross-connected the LAN ports of the two Brume 2 units and assigned a static IP address to eth1, it automatically performed Taildrop communication via the cross-connection. Smart!
Summary
I have introduced how I set up a failover configuration with two home servers using CloudFront's high availability feature, origin failover, and Tailscale Funnel.
Reference URLs
Discussion