Oct
09

Host Your Own Website for Free: The Ultimate Self-Hosting Guide (Custom Domain, SSH & SSL)

Stop paying monthly hosting fees! This comprehensive guide shows you exactly how to host your own secure website completely free using hardware you already own (a home server or VM).

Stop paying monthly hosting fees! This comprehensive guide shows you exactly how to host your own secure website completely free using hardware you already own (a home server or VM).

We break down the entire technical process—from spinning up the server to configuring network segmentation and deploying enterprise-grade security with SSL encryption and key-based SSH login. This is the definitive foundation for running a secure and cost-effective HomeLab.

Part 1: Setting Up the Secure Server Foundation

A secure, reliable website starts with a robust operating system (OS) foundation that is easily segmentable and updateable.

1. Virtual Machine (VM) Creation

Instead of dedicated hardware, we use virtualization for flexibility, although bare metal installation works just as well.

  • Platform: Use Proxmox, VirtualBox, or VMware.
  • OS Installation: Mount the latest Ubuntu Server ISO.
  • Resource Allocation: Allocate sufficient resources for smooth operation (e.g., 2 CPU Cores, 4 GB RAM, 20 GB Storage).

2. Static IP and Network Configuration

A critical step for self-hosting is ensuring your server has a static, predictable address on your network.

  • Installation: Proceed through the standard Ubuntu installation, defining the hostname and creating a user.
  • Manual IP Setup: During network configuration, switch to the manual IPv4 setup. Assign a static IP address within a designated subnet (e.g., 10.10.10.110) and set a public, reliable DNS server (e.g., 8.8.8.8 or 1.1.1.1).
  • Updates: Complete the foundation by running sudo apt update and sudo apt upgrade -y.

Part 2: Installing Apache and External Access (Port Forwarding)

With the foundation set, the next step is installing the web server software and opening the necessary ports to the public internet.

3. Deploying the Web Server

  • Installation: Install the Apache web server by running:


  • Bash

  • sudo apt install apache2
    
  • Initial Status: Once installed, your server will immediately begin serving the default Apache web page, visible only within your local network (LAN) on Port 80.

4. Router Configuration: Port Forwarding

To make your website publicly accessible, you must redirect internet traffic from your router to your server's static IP.

  • Access Router: Log into your router's administration panel (usually at 192.168.0.1 or 10.10.10.1).
  • Firewall/Port Forwarding: Create two main rules:
    • Rule 1 (HTTP): Forward Port 80 to your server's static IP (e.g., 10.10.10.110).
    • Rule 2 (HTTPS): Forward Port 443 to your server's static IP. (This is essential for the later SSL step).
  • Verification: You should now be able to reach your website by typing your home's public IP address into any browser.

Part 3: Custom Domain and Secure SSL Encryption

Raw IP addresses are difficult for users to remember. We must point a custom domain at the server and secure the connection with an SSL certificate.

5. Configuring DNS (A Record)

  • Domain Registrar: Log into your domain provider (e.g., Ionos, GoDaddy, Namecheap).
  • Add A Record: Create an A Record that points your domain (e.g., www.yourdomain.com) to your home's public IP address.

6. Apache Virtual Host Setup

Your Apache server needs to know which domain name it is hosting.

  • Edit Config: Open the default Apache configuration file:


  • Bash

  • sudo nano /etc/apache2/sites-available/000-default.conf
    
  • Set ServerName: Inside the <VirtualHost *:80> block, add the line:


  • Bash

  • ServerName yourdomain.com
    
  • Reload Apache: Apply the changes:


  • Bash

  • sudo systemctl reload apache2
    

7. Deploying SSL Encryption (HTTPS)

SSL encryption is mandatory for security and browser trust. We use the free, automated tool Certbot.

  • Install Certbot: Install the tool and the Apache plugin:


  • Bash

  • sudo apt install certbot python3-certbot-apache
    
  • Automate SSL: Run the Certbot command. It will automatically detect your configured domain, obtain the free Let's Encrypt certificate, and modify your Apache configuration to enforce HTTPS on Port 443.


  • Bash

  • sudo certbot --apache
    
  • Verification: Your website is now running securely over HTTPS and available via your custom domain.

Part 4: Secure Remote Management (Key-Based SSH)

For reliable and secure remote management of your HomeLab server, you must disable password login and enforce key-based SSH authentication.

8. SSH Key Generation

  • Install OpenSSH: Ensure OpenSSH is installed on the server:


  • Bash

  • sudo apt install open-ssh-server -y
    
  • Generate Key on Main Machine: On your local machine (Windows/Mac/Linux), generate a secure SSH key pair:


  • Bash

  • ssh-keygen -t rsa -b 4096
    
    • Best Practice: Add a strong passphrase to your private key for an essential extra layer of protection.
  • Send Key: Use ssh-copy-id or manually send the public key to your server.

9. Secure Server Hardening

To complete the security setup, enforce the use of the new key and restrict access.

  • Setup Server Files: Log back into the server, create the .ssh folder, and place the contents of your public key into the authorized_keys file.
  • Set Permissions: Apply strict file permissions:


  • Bash

  • chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys
    
  • Test Login: You can now access your server remotely using a secure SSH key and passphrase, eliminating the need for weaker password authentication.

You now have a robust, secure, and free self-hosted web server—the perfect, secure foundation for all future HomeLab services and projects.


Contact

Missing something?

Feel free to request missing tools or give some feedback using our contact form.

Contact Us