Liam Mitchell's site

Cloudflare With Vultr

|

Motivation

There are plenty of tutorials online on how to setup a virtual private server, many of them using Vultr as the hosting provider. However, being new to web hosting, I was worried about the security of my server and how I should go about locking it down so that no one else could access it.

I did some research on the topic and decided on using Cloudflare Zero Trust to control access to my Vultr VPS. The end result requires very little compromise from my end and I can still manage and maintain services without any extra overhead, but all incoming connections to the server are blocked. Authentication is handled by Cloudflare, who in my opinion are a reputable security company, so that I don’t have to spend any time beyond the initial setup worrying about someone hijacking my hosted services.

The reason for writing this post is to summarize the steps I took so that I or anyone else can quickly mimic my setup in the future without having to piece together the various pages of documentation again to get to the same end result. I have linked to the official documentation from Cloudflare and Vultr where possible so that you can easily find clarification on any of the steps listed, and so that if you want to adjust the configurations I use, you’ll have the proper starting place from which to do so.

Contents

  1. Buy a domain
  2. Configure the domain
  3. Rent a VPS
  4. Install a tunnel
  5. Access your VPS from the browser
  6. Set the Vultr firewall
  7. Conclusion

1: Buy a domain name with Cloudflare

While it isn’t strictly necessary to use Cloudflare as your registrar, it will simplify the setup process of the server since you can quickly enable security settings for your domain and set up appropriate DNS records. The instructions below summarize the official Cloudflare documentation:

2: Configure the new domain’s security settings

There are some very simple steps you can take to increase the security of your domain. From the Cloudflare dashboard, click “Websites” and then select your new domain:

websites section

Use the side bar on the left hand side of the page to access all of the settings mentioned below:

website sidebar

I have linked to the relevant Cloudflare documentation page for each setting listed. Please read the linked page(s) carefully before altering any setting if you don’t already know what it does.

3: Rent a VPS from Vultr

It’s very straightforward to rent and deploy a VPS on Vultr with the web user interface. I will summarize the steps but really you can just follow the prompts and end up with the right product.

4: Install Cloudflare Tunnel

This next part is how we’ll permit users you explicitly allow via Cloudflare Zero Trust to access your VPS. I’ll be summarizing the official docs once again.

5: Access your VPS from the browser

Next up, we are going to add a self-hosted application to Cloudflare Zero Trust so that we can enable browser rendering of an SSH terminal, allowing you to securely access your VPS from any device. I am summarizing the official docs on adding a self-hosted application and enabling browser rendering.

6: Set the Vultr firewall

The last thing on the agenda is to restrict all incoming connections to the VPS, so that connecting through the Cloudflare tunnel is the only way to access the server. The nice thing about Vultr’s firewall interface is that it can be managed through the web portal, unlike an OS-level firewall like UFW where if you mess up your rules, you could get locked out. Regardless, we can actually block all incoming connections, since Cloudflare tunnels create outbound connections to Cloudflare’s network as explained here.

The below instructions are a summary of these ones from Vultr:

Conclusion

That’s it. You should now have a virtual private server hosted on Vultr that can only be managed by any users you have explicitly allowed through Cloudflare Zero Trust. You can use this VPS to host whatever services you want, and in order to access them over the internet, just return to the Vultr Firewall you set up and add a rule allowing access to the server over that port.

For instance, if you wanted to run a web server, you would probably open ports 80 and 443 to the internet. If you decided to use Cloudflare as your reverse proxy to the server, Vultr makes it easy to restrict access to a certain port by setting the “Source” for your rule to “Cloudflare”. You can take advantage of Cloudflare’s free DDoS protection and security settings and ensure that any traffic trying to bypass the proxy is blocked.


  1. See Synapse issue 6367 ↩︎

#vultr #cloudflare

reply to this post by email ↩