Librevious

Workbench · 14 April 2026

How I Secured My VPS with Tailscale and Cloudflare

Running a VPS with public services like a website can quickly become risky if ports are left wide open. I recently hardened my Ubuntu VPS using a combination of Tailscale, Cloudflare, and a strict UFW firewall for my private coding environment setup. This setup follows a true zero-trust model, ie nothing is trusted by default.


Initial Situation

My VPS had Nginx serving a website and SSH enabled. A quick check revealed the issue:

sudo ss -tulnp

Ports 22 (SSH), 80, and 443 were listening on 0.0.0.0, meaning they were potentially accessible to anyone scanning the public IP.


Step 1: Configure a Strict Firewall with UFW

I installed UFW and applied a default-deny policy for maximum security:

sudo apt install ufw -y
sudo ufw default deny incoming
sudo ufw default allow outgoing


Key changes made:

sudo ufw allow in on tailscale0

After applying the rules, I checked the final configuration:

sudo ufw status verbose


Step 2: Enable Tailscale SSH

In the Tailscale admin console, I enabled Tailscale SSH. This lets me connect securely using the VPS’s Tailscale IP instead of exposing the public SSH port.


Step 3: Verification

To confirm everything was working correctly:


Why This Setup Works So Well

This combination is effective because each tool plays a specific, complementary role:


Together, they create defense-in-depth:

The result is a much more secure server without sacrificing performance or usability.


Final Thoughts

This zero-trust approach — Tailscale for private access, Cloudflare for public services, and strict UFW rules — has significantly improved my VPS security. In the future, I plan to explore Cloudflare Tunnel for even stronger isolation (zero public ports at all).


Have you implemented a similar setup on your VPS? Do you prefer Tailscale, Cloudflare Tunnel, WireGuard, or another combination?

Note: This blog post was curated by AI. The ideas, thoughts, and real-world use cases described are entirely my own. Posts without this note are written solely by me.

Keep scrolling
to read next

Chasing the Last Light

Next still