Om Pandey
Cloud & Hosting

Cloud & Hosting

Master web hosting from static sites to full-stack deployment. Learn about domains, servers, databases, and deploy your projects to the world using free and paid platforms.

Domains & DNS VPS & Cloud Free Deployment
πŸ“š

What You'll Learn

Domains & URLs

Servers & Hosting

Databases

Web Tiers Architecture

Static vs Dynamic Sites

Free Hosting Platforms

Paid & VPS Hosting

Deploy Static Sites

Deploy Backend Apps

Custom Domain Setup

Cloudflare Tunnel

Ngrok for Testing

1

Understanding the Web

Domains & URLs

A domain is your website's address on the internet. It's like your home address but for websites. When someone types www.omkumarpandey.com.np in their browser, DNS (Domain Name System) translates it to an IP address where your website lives.

URL Structure: https://www.omkumarpandey.com.np/blog/post-1 β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚ └── Path β”‚ β”‚ β”‚ └── TLD (Top Level Domain) β”‚ β”‚ └── Domain Name β”‚ └── Subdomain (www) └── Protocol (HTTPS) Domain Types: β€’ .com, .org, .net β†’ Generic TLDs β€’ .com.np, .co.uk β†’ Country-code TLDs β€’ .dev, .app, .io β†’ New gTLDs Where to Buy Domains: β€’ Namecheap β†’ Affordable, good UI β€’ Cloudflare β†’ At-cost pricing β€’ GoDaddy β†’ Popular but pricey β€’ Google Domains β†’ Simple, transparent β€’ Local (.np) β†’ Register.com.np

πŸ’‘ Pro Tip

Buy domains from Cloudflare - they sell at wholesale price with no markup! For .np domains, you'll need to register through Nepal's domain registrar.

Servers & Hosting

A server is a computer that stores your website files and serves them to visitors. When someone visits your site, their browser sends a request to the server, which responds with the HTML, CSS, JavaScript, and other files needed to display your page.

How Web Hosting Works: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Browser β”‚ ──────▢ β”‚ DNS β”‚ ──────▢ β”‚ Server β”‚ β”‚ (Client) β”‚ β”‚ (Lookup) β”‚ β”‚ (Host) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ │◀──────────── Website Files ───────────────────│ Types of Hosting: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Shared Hosting β†’ Multiple sites on one server β”‚ β”‚ β†’ Cheap ($3-10/mo), Limited control β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ VPS Hosting β†’ Virtual private server β”‚ β”‚ β†’ More control, scalable ($5-50/mo) β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ Dedicated Server β†’ Entire server for you β”‚ β”‚ β†’ Full control, expensive ($80+/mo) β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ Cloud Hosting β†’ Pay for what you use β”‚ β”‚ β†’ AWS, GCP, Azure (Variable pricing) β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ Static Hosting β†’ For HTML/CSS/JS only β”‚ β”‚ β†’ FREE! (Netlify, Vercel, GitHub) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Databases

Databases store and organize your application's data - user accounts, blog posts, products, etc. Static sites don't need databases, but dynamic applications do.

Database Types: SQL (Relational) NoSQL (Non-relational) β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β€’ PostgreSQL β”‚ β”‚ β€’ MongoDB β”‚ β”‚ β€’ MySQL β”‚ β”‚ β€’ Redis β”‚ β”‚ β€’ SQLite β”‚ β”‚ β€’ Firebase β”‚ β”‚ β€’ MariaDB β”‚ β”‚ β€’ DynamoDB β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ Tables with rows/columns Documents/Key-value pairs Structured data Flexible schema ACID compliant Highly scalable Free Database Options: β€’ Supabase β†’ PostgreSQL (Free tier: 500MB) β€’ PlanetScale β†’ MySQL (Free tier: 5GB) β€’ MongoDB Atlas β†’ MongoDB (Free tier: 512MB) β€’ Firebase β†’ NoSQL (Generous free tier) β€’ Neon β†’ PostgreSQL (Free tier available)

Web Tiers Architecture

Modern web applications are built in layers (tiers). Understanding this architecture helps you know what you need for your project and where to host each component.

3-Tier Architecture: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ FRONTEND (Presentation) β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ HTML β”‚ CSS β”‚ JavaScript β”‚ React/Vue/Angular β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ What users see and interact with in browser β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ BACKEND (Application) β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ Django β”‚ Node.js β”‚ FastAPI β”‚ Flask β”‚ Express β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ Business logic, API endpoints, authentication β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ DATABASE (Data) β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ PostgreSQL β”‚ MySQL β”‚ MongoDB β”‚ Redis β”‚ SQLiteβ”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ Stores and retrieves application data β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🎯 Key Insight

Static sites only need the Frontend tier β†’ FREE hosting available!
Dynamic sites need all 3 tiers β†’ Requires paid hosting or clever free solutions.

Static vs Dynamic Sites

Understanding the difference is crucial for choosing the right hosting solution.

Feature Static Sites Dynamic Sites
Content Fixed HTML/CSS/JS files Generated on each request
Backend βœ— Not needed βœ“ Required
Database βœ— Not needed βœ“ Usually needed
User Accounts βœ— Not possible βœ“ Supported
Speed ⚑ Very fast (CDN) πŸ”„ Depends on server
Security πŸ›‘οΈ Very secure ⚠️ More attack vectors
Cost πŸ’š FREE πŸ’° $5-100+/month
Examples Portfolio, Blog, Docs E-commerce, Social Media
2

Host Static Sites for FREE

If your website is just HTML, CSS, and JavaScript (no backend, no database), you can host it completely FREE on these amazing platforms. Perfect for portfolios, landing pages, and documentation!

GitHub Pages

Host directly from your GitHub repository

FREE

Netlify

Auto-deploy from Git with custom domains

FREE

Vercel

Best for Next.js, great for any static site

FREE

Cloudflare Pages

Fast CDN, unlimited bandwidth

FREE

Firebase Hosting

Google's hosting with free SSL

FREE

Surge.sh

Simple CLI-based deployment

FREE

Deploy with GitHub Pages

GitHub Pages is the easiest way to host a static site. It's free, supports custom domains, and automatically deploys when you push to your repository.

1
Create a GitHub Repository Push your website files to GitHub
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/yourusername/your-repo.git
git push -u origin main
Files uploaded to GitHub
2
Enable GitHub Pages Settings β†’ Pages β†’ Select branch

1. Go to your repository on GitHub
2. Click Settings β†’ Pages
3. Under "Source", select main branch
4. Click Save

Site live at: https://yourusername.github.io/your-repo/
3
Add Custom Domain (Optional) Use your own domain like www.omkumarpandey.com.np

1. In GitHub Pages settings, enter your custom domain
2. Create a CNAME file in your repo with your domain
3. Add DNS records at your domain registrar:

# Add these DNS records:

Type: CNAME
Name: www
Value: yourusername.github.io

# Or for apex domain (A records):
185.199.108.153
185.199.109.153
185.199.110.153
185.199.111.153
Site live at: www.omkumarpandey.com.np

Deploy with Netlify

Netlify offers automatic deployments from Git, serverless functions, form handling, and more. It's perfect for modern static sites and JAMstack applications.

1
Connect Repository Link your GitHub/GitLab repo to Netlify

1. Go to netlify.com and sign up
2. Click "Add new site" β†’ "Import an existing project"
3. Connect your GitHub account
4. Select your repository

Repository connected
2
Configure Build Settings Set build command and publish directory
# For plain HTML/CSS/JS:
Build command: (leave empty)
Publish directory: / or ./public

# For React/Vue/Angular:
Build command: npm run build
Publish directory: dist or build
Site deployed at: random-name.netlify.app
3
Add Custom Domain Configure your own domain

1. Go to Site settings β†’ Domain management
2. Click "Add custom domain"
3. Enter your domain: www.omkumarpandey.com.np
4. Add the DNS records Netlify provides

# DNS Records to add:

Type: CNAME
Name: www
Value: your-site.netlify.app

# Enable HTTPS (automatic with Netlify)
Site live with SSL at your custom domain!

✨ Netlify Bonus Features

β€’ Auto-deploy on every git push β€’ Free SSL certificates β€’ Form submissions β€’ Serverless functions β€’ Split testing β€’ Deploy previews for pull requests

Deploy with Cloudflare Pages

Cloudflare Pages offers unlimited bandwidth, automatic deployments, and blazing-fast performance through Cloudflare's global CDN network.

Cloudflare Pages Setup
# Step 1: Go to Cloudflare Dashboard
β†’ https://dash.cloudflare.com
β†’ Click "Pages" in sidebar
β†’ Click "Create a project"

# Step 2: Connect Git Repository
β†’ Connect to GitHub/GitLab
β†’ Select your repository
β†’ Configure build settings:
   β€’ Build command: (empty for static, or npm run build)
   β€’ Output directory: / or dist or build

# Step 3: Deploy
β†’ Click "Save and Deploy"
β†’ Wait for build to complete
β†’ Site live at: your-project.pages.dev

# Step 4: Custom Domain
β†’ Go to your project β†’ Custom domains
β†’ Add: www.omkumarpandey.com.np
β†’ Cloudflare auto-configures DNS if domain is on Cloudflare!

πŸš€ Why Cloudflare Pages?

Unlimited bandwidth (even on free tier), 300+ edge locations worldwide, and if your domain is already on Cloudflare, custom domain setup is instant!

3

Hosting Platforms Overview

Different projects need different hosting solutions. Here's a comprehensive overview of all major hosting options, from free to enterprise-grade.

Free Hosting Platforms

Platform Best For Features Limitations
GitHub Pages Static sites Custom domain, SSL 1GB storage, no backend
Netlify JAMstack, Static Functions, Forms, CDN 100GB bandwidth/mo
Vercel Next.js, Frontend Edge functions, Fast 100GB bandwidth/mo
Cloudflare Pages Static + Workers Unlimited bandwidth! 500 builds/mo
Railway Full-stack apps Database, Backend $5 free credit/mo
Render Web services Static + Backend Sleeps after 15min
Fly.io Docker apps Global deployment 3 shared VMs free

Paid & VPS Hosting

AWS

Industry standard, highly scalable

Google Cloud

Great for ML and big data

Microsoft Azure

Enterprise-grade cloud

DigitalOcean

Developer-friendly VPS

Linode

Simple, reliable VPS

Vultr

High-performance cloud

Heroku

Easy PaaS deployment

cPanel Hosting

Traditional shared hosting

⚠️ Important Note

Heroku removed their free tier in 2022. For free backend hosting alternatives, check out Railway, Render, or Fly.io. For testing, use Ngrok or Cloudflare Tunnel!

4

Deploy Backend Applications

Backend applications (Django, Node.js, FastAPI, Flask) require a server that can run your code. Here are your options from free testing to production deployment.

Backend Frameworks & Deployment

Popular Backend Frameworks: Python JavaScript Other β”œβ”€β”€ Django β”œβ”€β”€ Node.js + Express β”œβ”€β”€ Ruby on Rails β”œβ”€β”€ FastAPI β”œβ”€β”€ Next.js (API) β”œβ”€β”€ PHP Laravel β”œβ”€β”€ Flask β”œβ”€β”€ Nest.js β”œβ”€β”€ Go Gin └── Pyramid └── Fastify └── Rust Actix Deployment Options: β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ For Testing (FREE) β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ β€’ Ngrok β†’ Expose localhost to internet β”‚ β”‚ β€’ Cloudflare Tunnel β†’ Permanent tunnels, custom domains β”‚ β”‚ β€’ LocalTunnel β†’ Simple temporary URLs β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ For Production (FREE/Cheap) β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ β€’ Railway β†’ $5 free credit, easy deployment β”‚ β”‚ β€’ Render β†’ Free tier (sleeps after 15min) β”‚ β”‚ β€’ Fly.io β†’ 3 free shared VMs β”‚ β”‚ β€’ Vercel β†’ Serverless functions β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ For Production (PAID) β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ β€’ VPS (DigitalOcean, Linode, Vultr) β†’ Full control β”‚ β”‚ β€’ AWS EC2 / Lightsail β†’ Scalable β”‚ β”‚ β€’ Heroku β†’ Easy PaaS β”‚ β”‚ β€’ cPanel β†’ Traditional β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Testing with Ngrok

Ngrok creates a secure tunnel from a public URL to your local machine. Perfect for testing webhooks, sharing work with clients, or mobile app development.

terminal
# Install Ngrok
# Download from https://ngrok.com/download

# Or with npm
npm install -g ngrok

# Or with snap (Linux)
sudo snap install ngrok

# Authenticate (get token from ngrok.com)
ngrok config add-authtoken YOUR_AUTH_TOKEN

# Start your local server first
python manage.py runserver 8000    # Django
npm run dev -- --port 3000          # Node.js

# Expose local server to internet
ngrok http 8000

# Output:
Forwarding: https://abc123.ngrok.io β†’ http://localhost:8000

πŸ’‘ Ngrok Limitations

Free tier: Random URLs that change each session, 40 connections/minute. For permanent URLs, use Cloudflare Tunnel (free) or upgrade Ngrok ($8/mo).

VPS Deployment (Production)

For production Django, Node.js, or FastAPI apps, a VPS gives you full control. Here's a quick overview of deploying a Django app.

VPS Setup - Ubuntu
# 1. SSH into your VPS
ssh root@your-server-ip

# 2. Update system
sudo apt update && sudo apt upgrade -y

# 3. Install required packages
sudo apt install python3-pip python3-venv nginx -y

# 4. Clone your project
git clone https://github.com/yourname/project.git
cd project

# 5. Create virtual environment
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

# 6. Install Gunicorn (WSGI server for Django)
pip install gunicorn

# 7. Test Gunicorn
gunicorn --bind 0.0.0.0:8000 yourproject.wsgi

# 8. Configure Nginx as reverse proxy
sudo nano /etc/nginx/sites-available/yourproject

# 9. Enable site and restart Nginx
sudo ln -s /etc/nginx/sites-available/yourproject /etc/nginx/sites-enabled
sudo systemctl restart nginx

# 10. Set up SSL with Certbot (Let's Encrypt)
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d yourdomain.com
5

Cloudflare Tunnel (Detailed Guide)

Cloudflare Tunnel lets you expose your local server to the internet with a custom domain, SSL, and DDoS protection - all for FREE! Perfect for hosting Django, Node.js, or any backend app from your own computer or a local server.

🎯 What You'll Achieve

By the end of this guide, your local Django/Node.js app running on localhost:8000 will be accessible at https://enyx.omkumarpandey.com.np with full SSL!

1
Install cloudflared on Linux Required for Cloudflare Tunnel
sudo apt update
sudo apt install cloudflared

For other systems:

# macOS
brew install cloudflare/cloudflare/cloudflared

# Windows - Download from:
# https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/install-and-setup/installation
cloudflared command available
2
Login to Cloudflare Generates origin certificate for authentication
cloudflared tunnel login

This opens a browser window. Select the domain you want to use (e.g., omkumarpandey.com.np). Your domain must be added to Cloudflare first!

cert.pem created in ~/.cloudflared/
3
Verify Certificate File Make sure authentication succeeded
ls ~/.cloudflared
Expected Output
cert.pem
cert.pem visible - ready to create tunnel
4
Create Tunnel Permanent named tunnel for your project
cloudflared tunnel create enyx-tunnel

Replace enyx-tunnel with any name you want for your tunnel.

Expected Output
Tunnel credentials written to /home/user/.cloudflared/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.json Created tunnel enyx-tunnel with id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Tunnel ID + JSON credentials file created
5
List Tunnels Confirm tunnel was created successfully
cloudflared tunnel list
Expected Output
ID NAME CREATED xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx enyx-tunnel 2024-01-15T10:30:00Z
enyx-tunnel listed
6
Route DNS to Tunnel Connect your subdomain to the tunnel
cloudflared tunnel route dns enyx-tunnel enyx.omkumarpandey.com.np

This automatically creates a CNAME record in your Cloudflare DNS pointing to your tunnel.

CNAME record auto-created in Cloudflare DNS
7
Create Configuration File Define hostname routing rules
nano ~/.cloudflared/config.yml

Add the following configuration:

~/.cloudflared/config.yml
tunnel: enyx-tunnel credentials-file: /home/YOUR_USERNAME/.cloudflared/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.json ingress: - hostname: enyx.omkumarpandey.com.np service: http://localhost:8000 - service: http_status:404

⚠️ Important

Replace YOUR_USERNAME with your actual Linux username, and use the actual tunnel ID from step 4 for the credentials file path!

Config file saved
8
Run Your Application Server Your app must be running locally first
# For Django
python manage.py runserver 0.0.0.0:8000

# For Node.js/Express
node app.js # or npm start

# For FastAPI
uvicorn main:app --host 0.0.0.0 --port 8000
Application running on localhost:8000
9
Start Cloudflare Tunnel Expose your local app to the internet

Open a new terminal window (keep your app running) and start the tunnel:

cloudflared tunnel run enyx-tunnel
Expected Output
2024-01-15T10:45:00Z INF Starting tunnel tunnelID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx 2024-01-15T10:45:00Z INF Connection established connIndex=0 2024-01-15T10:45:00Z INF Connection established connIndex=1 2024-01-15T10:45:01Z INF Connection established connIndex=2 2024-01-15T10:45:01Z INF Connection established connIndex=3
Tunnel connected! 4 connections established.
10
Configure Django Settings Prevent 400 Bad Request errors

Add your tunnel domain to Django's allowed hosts:

settings.py
# Add your tunnel domain to allowed hosts ALLOWED_HOSTS = [ 'localhost', '127.0.0.1', 'enyx.omkumarpandey.com.np', ] # For forms and CSRF protection CSRF_TRUSTED_ORIGINS = [ 'https://enyx.omkumarpandey.com.np', ]

For Node.js/Express: No special configuration needed!
For FastAPI: Configure CORS if needed.

Django configured for tunnel domain
11
Final Test Open your site in the browser
https://enyx.omkumarpandey.com.np

πŸŽ‰ Congratulations!

Your local application is now live on the internet with:
βœ… Custom domain
βœ… Free SSL certificate
βœ… DDoS protection
βœ… Cloudflare CDN

Run Tunnel as a Service (Bonus)

To keep the tunnel running even after you close the terminal or reboot, install it as a system service:

terminal
# Install cloudflared as a service
sudo cloudflared service install

# Start the service
sudo systemctl start cloudflared

# Enable on boot
sudo systemctl enable cloudflared

# Check status
sudo systemctl status cloudflared

# View logs
sudo journalctl -u cloudflared -f

πŸ’‘ Multiple Subdomains

You can route multiple services through one tunnel! Just add more hostnames to your config.yml ingress rules, each pointing to different local ports.

6

Quick Reference

Hosting Decision Flowchart

What type of site do you have? β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Your Website β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚ β–Ό β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Static Site β”‚ β”‚ Dynamic Site β”‚ β”‚ HTML/CSS/JS β”‚ β”‚ Backend + DB β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β–Ό β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ FREE Hosting! β”‚ β”‚ Need Server β”‚ β”‚ β€’ GitHub Pagesβ”‚ β””β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β€’ Netlify β”‚ β”‚ β”‚ β€’ Vercel β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β€’ Cloudflare β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β–Ό β–Ό β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Testing Only β”‚ β”‚ Production β”‚ β”‚ β€’ Ngrok β”‚ β”‚ β€’ VPS ($4+/mo)β”‚ β”‚ β€’ CF Tunnel β”‚ β”‚ β€’ Railway β”‚ β”‚ β€’ LocalTunnel β”‚ β”‚ β€’ Render β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β€’ Fly.io β”‚ β”‚ β€’ Heroku β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Common Commands Cheatsheet

cheatsheet.sh
# ===== CLOUDFLARE TUNNEL =====
cloudflared tunnel login                    # Authenticate
cloudflared tunnel create NAME              # Create tunnel
cloudflared tunnel list                     # List tunnels
cloudflared tunnel route dns NAME SUBDOMAIN # Add DNS
cloudflared tunnel run NAME                 # Start tunnel
cloudflared tunnel delete NAME              # Delete tunnel

# ===== NGROK =====
ngrok http 8000                             # Expose port 8000
ngrok http 3000 --subdomain=myapp           # Custom subdomain (paid)

# ===== NETLIFY CLI =====
npm install -g netlify-cli                  # Install
netlify login                               # Authenticate
netlify deploy                              # Deploy draft
netlify deploy --prod                       # Deploy production

# ===== VERCEL CLI =====
npm install -g vercel                       # Install
vercel login                                # Authenticate
vercel                                      # Deploy
vercel --prod                               # Deploy production

# ===== GIT COMMANDS =====
git add .                                   # Stage all files
git commit -m "message"                     # Commit
git push origin main                        # Push to GitHub

πŸš€ Ready to Deploy?

You now have all the knowledge to host any website - from simple portfolios to complex web applications!

Learn Django Development