Table of contents
Why?
My three modest Laravel apps must be moved to another host after receiving notification from Heroku that they are no longer offering "Free Service." I'm done, thank you. I've made the decision to relocate every app to my self-hosted home Lab.
I found it is easy to use virtulisation or compartlisation/container to host my apps. And I have two technology in mind, proxmox/truenas Scale and Docker/kubernety. I started with Ubuntu VM inside a Virtual Box Container and docker. For testing purpose this is fast and snapshot makes redo my mistake easy. I learned that using virtualization or a container to host my apps is simple. Additionally, I'm thinking of the technologies Docker/Kubernetes and Proxmox/Truenas Scale. I started by utilising an Ubuntu-powered Virtual Box VM running Docker. This is quick for testing, and the snapshot feature makes it simple to fix my error.
I use JIO Fiber, and my monthly usage is roughly 1 TB, mostly downloads, with a 3.3 TB plan cap. Using CF Tunnel, I found that hosting at home is really simple.
Why Not?
To be clear, this website is hosted on my fragile consumer home fibre line. Uptime is not guaranteed. Also, the server is unreliable. This is being hosted in an Atom Net Book on a very unreliable spinning hard drive.
Security
I don't have to reveal my real IP address or leave router ports open when using the CloudFlare tunnel. CloudFlare Tunnel controls all ingress traffic end to end. Because CloudFlare Tunnel will automatically produce and use a wildcard certificate for me, I don't even need to create an SSL certificate. This, in my opinion, is more secure than opening ports and disclosing your IP online.
How?
Well, I use my subdomain and the CloudFlare tunnel to expose my apps.
Let's test with a Virtual Box VM. Virtual boxes are simpler to build and destroy than actual systems.
What you need to get started is a brand-new installation of Ubuntu with ssh access. Here are the details of my Ubuntu virtual machine.
Please make use of ssh to avoid using the VM's terminal.
SSH into the system now, and upgrade every component.
sudo apt update
sudo apt upgrade
Docker and Portainer installation are the next steps. Please refer to this guide for installing Docker.
https://docs.docker.com/engine/install/ubuntu/
Please follow this tutorial for Portainer.
https://docs.portainer.io/start/install/server/docker/linux
You will end up with this Portnair admin dashboard if you complete the guide.
Here's the greatest part: I'm now hosting a website on the virtual machine using CloudFlare Tunnel. You can read more about how this works here. here
I will now set up the tunnel using the cli. If you want to proceed, you can do so by following this guide. Step by step guide to setup CloudFlare tunnel
You can now visit the site url that is hosted in your VM if the tunnel was properly setup and configured.
I've used this configuration to utilise a URL to access my Portainer installation. A webpage is forwarded to by my localhost:port. However, I didn't reveal my IP address, alter any DNS, or open any ports on my network. Additionally, the website has a current SSL Certificate from CloudFlare. So for me, using my own hardware to SelfHost parts of my websites makes perfect sense. The setup I'm using to host Portainer Dashboard is shown below. On the same virtual private server, I also host a Laravel application that can be accessed at "laravel9.example.site."
tunnel: please-input-your-tunnel-id-here
credentials-file: /home/user/.cloudflared/please-input-your-tunnel-id-here.json
ingress :
- hostname: laravel9.example.site
service: http://localhost:8000
- hostname: portainer.example.site
originRequest:
noTLSVerify: true
service: https://localhost:9443
- service: http_status:404
Note : noTLSVeryfy will accept any SSL Certificate; otherwise, a 502 error will be returned.
originRequest:
noTLSVerify: true
My Use Case?
For a brief amount of time, it is much more stable than other tunnels, so I wanted to host some of my apps and share them with my friends. I can use a single tunnel to host numerous sites. Additionally, it is incredibly simple to configure and utilise when used with Docker. I hope to use some extra PCs I have as a home server using a CloudFlare tunnel.
Conclusion?
I've used a lot of free hosting plans and discovered that they are either useless or feature crummy free tire. I've spent a lot of time experimenting with them as well. I value code control, therefore using CloudFlare to host supplemental preview sites is my second-best option.