
Cloud services like AWS, Google Cloud, Azure, Heroku, and Vercel offer significant advantages, including powerful features and ease of use. However, for hobby projects or small-scale applications, these services can be costly and may exceed what’s needed. I realized that paying for cloud services didn't make sense for my small projects. Even [<span class="text-slate-300 underline">DHH</span>](https://world.hey.com/dhh/why-we-re-leaving-the-cloud-654b47e0) has opted to move away from cloud hosting. Inspired by my talented friends [<span class="text-slate-300 underline">Eralp</span>](https://github.com/eralpkaraduman), [<span class="text-slate-300 underline">Mehmet</span>](https://github.com/strada), and [<span class="text-slate-300 underline">Baris</span>](https://github.com/brsbyrk), I decided to host my projects on a Raspberry Pi. I will share my journey of setting up self-hosting using Coolify, Raspberry Pi, and Cloudflare, providing a practical guide for others who want to do the same. ## <span class="text-slate-300">Introduction</span> ### <span class="text-slate-300">Why Choose Self-Hosting?</span> - Self-hosting is affordable, accessible, and offers the opportunity to gain hands-on experience with web servers, Docker, networking, and other technical skills. It’s a great way to learn and experiment without the constraints and costs associated with cloud providers. ### <span class="text-slate-300">Why Raspberry Pi?</span> - Raspberry Pi is affordable, compact, and powerful enough for hosting small to medium projects. It’s an ideal choice for hobbyists and developers who want to experiment without breaking the bank. Its low power consumption and small footprint make it perfect for running a server at home or in a small office. ### <span class="text-slate-300">Why Coolify?</span> - Coolify was created to provide a simpler, more cost-effective alternative to platforms like Vercel. The founder sought to eliminate the expensive bills associated with traditional cloud services. Coolify offers many of the same features, allowing you to self-host your applications without the high costs. For more information about the project, visit their [<span class="text-slate-300 underline">GitHub page</span>](https://github.com/coollabsio/coolify). ### <span class="text-slate-300">Why Cloudflare Tunnels?</span> - I wanted to avoid exposing my ports directly to the internet. Since I don’t have a static IP, managing IP changes can be cumbersome. Cloudflare Tunnels provided a convenient solution for securely accessing my applications. For more information, check out [<span class="text-slate-300 underline">Rasmus's guide</span>](https://rasmusgodske.com/posts/securely-expose-your-coolify-apps-with-the-magic-of-cloudflare-tunnels/) on setting up Cloudflare Tunnels. ## <span class="text-slate-300">Setting Up the Raspberry Pi</span> 1. ## <span class="text-slate-300">Choosing an Operating System</span> - The minimum recommended server specifications for Coolify are 2 CPUs and 2GB of memory. The Raspberry Pi 4B with 4GB of memory is suitable for this. Coolify recommends using Raspberry Pi OS, which you can learn more about on their [<span class="text-slate-300">website</span>](https://coolify.io/docs/installation).  2. ## <span class="text-slate-300">Configuring the OS</span> - After selecting the OS, configure the settings. Make sure to hide any sensitive information (e.g., Wi-Fi names, passwords) in your screenshots.   3. ## <span class="text-slate-300">Setting Up Hostname, Username, and Password</span> - Configure a hostname, username, and password for the Raspberry Pi. These will be used for SSH connections. You can also create an SSH key under the options to make future logins more secure.   4. ## <span class="text-slate-300">Connecting to the Raspberry Pi</span> - Once the OS setup is complete, connect to the Raspberry Pi's terminal via SSH. You’re now ready to install Coolify. Follow the [<span class="text-slate-300 underline">Coolify installation guide</span>](https://coolify.io/docs/installation/). After installation, you can access Coolify at http://raspberry_hostname:8000. - For a detailed video tutorial on setting up Coolify, I recommend watching the [<span class="text-slate-300 underline">Syntax YouTube channel tutorial</span>](https://www.youtube.com/watch?v=taJlPG82Ucw). ## <span class="text-slate-300">Setting Up Cloudflare Tunnel</span> 1. ### <span class="text-slate-300">Create a Tunnel in Cloudflare</span> - After installing Coolify, visit the Cloudflare dashboard and create a tunnel. Go to the "Zero Trust" section on the left.  2. ### <span class="text-slate-300">Access Tunnels Under the Network Section</span> - You can find the tunnels listed under "Networks."  3. ### <span class="text-slate-300">Install Cloudflared on Raspberry Pi</span> - Follow the recommended Cloudflared installation steps. When using Docker, run the provided commands on the Raspberry Pi.   4. ### <span class="text-slate-300">Configure the Tunnel to Your Raspberry Pi Hostname and Ports</span> - Ensure the tunnel is configured to point to your Raspberry Pi's hostname and the appropriate ports.  5. ### <span class="text-slate-300">Verify the Tunnel Status</span> - Go back to the tunnels list to confirm that the tunnel status is "Healthy." You can also verify the tunnel is running by executing <span class="text-slate-300 underline">docker ps</span> on the Raspberry Pi. ## <span class="text-slate-300">Deploying an Application with Coolify</span> 1. ### <span class="text-slate-300">Create a Project in Coolify</span> - Start by creating a new project in Coolify.  2. ### <span class="text-slate-300">Connect to Your GitHub Repository</span> - Link your project to a GitHub repository for continuous deployment.  3. ### <span class="text-slate-300">Create a New Application</span> - Set up the application and configure its deployment settings.  4. ### <span class="text-slate-300">Map the Application to Port 80 for the Cloudflare Tunnel</span> - Make sure your application is accessible through port 80 for the Cloudflare Tunnel configuration.  5. ### <span class="text-slate-300">Verify the Application Deployment</span> - After deploying, you should be able to access your application via the domain configured with Cloudflare. ## <span class="text-slate-300">Conclusion</span> Self-hosting your projects using a Raspberry Pi, Coolify, and Cloudflare Tunnels provides a unique opportunity to learn about infrastructure management and deploying web applications. By taking control of your own hosting, you not only save on costs but also gain deeper knowledge of the deployment process. Self-hosting empowers you with full control over your projects, enabling greater customization and flexibility. I encourage you to try this setup for your own projects and explore the world of self-hosting. Feel free to reach out or share your experiences – I'd love to hear about your journey!