Portfolio Website

Ditching Paid Hosting and Building My Own Server from Scratch

How I Built and Host My Own Web App — Saving Over $225 a Year While Gaining Full Control.

I built and deployed a secure web app using Flask, Nginx, and Gunicorn—hosted on my own Raspberry Pi. No third parties. No bills. Just performance, control, and peace of mind.

How it all started

As a web developer, I always strive to build solutions that are not only functional and secure, but also cost-effective and self-reliant. My personal website, sergeiweb.com, started as a simple static page hosted on GitHub Pages. It has since evolved into a full-fledged web application, fully deployed and maintained on my own custom-built server. Today, the site runs on a Raspberry Pi 4 Model B (4 GB RAM, 64-bit), powered by Raspberry Pi OS (Bookworm), and leverages a robust backend stack: Flask for the application logic, Gunicorn as the WSGI server, and Nginx to handle incoming traffic and HTTPS. Everything is hosted from my home setup—no third-party platforms involved. The frontend was handcrafted using HTML, CSS, and JavaScript with responsive design principles. On the backend, Flask also powers an administrative panel built with Flask-Admin, which gives me full control over the site’s content—allowing me to create, edit, and delete blog posts without touching the codebase or database directly. I use SQLite for storage, but the site’s architecture is flexible enough to switch to PostgreSQL whenever needed.

Security and stability were top priorities.

picture of the Pi

Small but powerful box

HTTPS is managed with Let’s Encrypt and Certbot for automatic certificate renewal. My hosting provider already offers a static IPv4 address, but just to be safe, I wrote a Python script that automatically checks for any IP changes and updates the domain settings without requiring any manual input via a cron job. This ensures maximum reliability without relying on services like DuckDNS. I also have the secure server access with SSH keys, firewall rules (ufw), and intrusion prevention via fail2ban. System performance is continuously monitored using htop, iotop, nload, and vcgencmd. Backups of both the site and its database are generated regularly through cron jobs and stored locally as well as on external media. Everything is version-controlled, with dependencies locked in a requirements.txt file, and deployments are handled via custom shell scripts—allowing for rapid recovery or replication of the environment when needed. Initially, I hosted the live Flask application on Render’s paid platform at $19/month. However, after a sudden, week-long outage during a crucial round of interviews—and zero response from support—I realized the importance of controlling my infrastructure. That experience pushed me to move away from dependency on commercial hosting altogether. The result? Not only do I have a more resilient and customizable environment, but I’m also saving over $225 annually—a practical win that reflects both my problem-solving mindset and my commitment to sustainable development practices.

Raspberry in the box

The price to pay for your independance

When I decided to move away from third-party hosting services, I aimed for a solution that was not only technically robust but also cost-effective and independent. I built a completely headless server setup using a Raspberry Pi 4 Model B (4GB RAM) — no monitor, keyboard, or mouse required. The entire system is configured, deployed, and maintained remotely via SSH, which keeps the hardware footprint minimal and energy consumption low. The full cost of this self-hosted infrastructure was just $120.30, covering the Raspberry Pi itself, an armor case with dual cooling fans, a 15W USB-C power supply, a 32GB microSD card preloaded with Raspberry Pi OS, and a compact external case for protection.

This one-time investment replaced a $19/month Render hosting plan, saving me over $225 annually. In just six months, the setup pays for itself — with zero recurring fees and no dependency on commercial platforms. One of the biggest advantages of this setup is complete mobility and control. Using VPN access via a lightweight VPS, or through apps like Terminus combined with Tailscale, I can securely manage and control my web application directly from my phone — anytime, anywhere. And the best part? This layer of remote control is also free. No additional paid tools, no subscriptions. Just smart, efficient engineering. Here is my order:

Item Details
Raspberry Pi 4 Model B/4GB (SKU: 4GB-9004) $55.00 x1 = $55.00
HighPi Pro Case for Raspberry Pi 4 (SKU: 9060) $10.95 x1 = $10.95
Official Raspberry Pi microSD Card with Raspberry Pi OS 32-bit - 32GB (SKU: 1363-1) $12.95 x1 = $12.95
Raspberry Pi 15W USB-C Power Supply, EU, Black (SKU: 1707-EU) $8.00 x1 = $8.00
Armor Case with Dual Fan for Raspberry Pi 4 Model B - Black (SKU: 1730) $12.95 x1 = $12.95
Subtotal $99.85
Shipping $10.64
Tax $9.81
Grand Total $120.30
Building and hosting this web application from scratch taught me far more than just writing code. It gave me real-world experience in DevOps, security hardening, cost management, and infrastructure planning. And it’s a strong reminder that sometimes, the best way to future-proof your work is to own the tools behind it.

Published on: April 09, 2025

Author: admin