Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8015

Teaching and learning resources • Tutorial: Hosting a website on Raspberry Pi 5 with FreeDNS and Let’s Encrypt (Home Setup)

$
0
0
Hosting your own website from home with a Raspberry Pi is completely possible, and with free tools like freedns.afraid.org and Let’s Encrypt, you don’t even need to buy a domain or SSL certificate.

Below is a step-by-step guide.

1. Requirements
  • Raspberry Pi 5 (with Raspberry Pi OS installed)
  • Stable internet connection
  • Router with admin access (for port forwarding)
  • FreeDNS account (https://freedns.afraid.org)
  • Installed web server (Nginx or Apache; here I’ll use Nginx)
2. Set a Static LAN IP for Your Pi
You don’t want your Pi’s IP address to change on your local network.
  1. Edit the dhcpcd.conf file:

    Code:

    sudo nano /etc/dhcpcd.conf
  2. Add something like this at the bottom (adjust to your network):

    Code:

    interface eth0static ip_address=192.168.1.100/24static routers=192.168.1.1static domain_name_servers=8.8.8.8 1.1.1.1
    • 192.168.1.100 → your Pi’s fixed LAN IP
    • 192.168.1.1 → your router’s IP (gateway)
  3. Reboot:

    Code:

    sudo reboot
Now your Pi always has the same internal IP.

3. Configure FreeDNS Subdomain
  1. Go to freedns.afraid.org
  2. Choose a subdomain from the Subdomains → Add section. Example:
  3. If your ISP changes your IP often, enable Dynamic DNS:
    • FreeDNS provides a special update URL you can call with a script or cron job to keep your IP updated.
4. Router Port Forwarding
To make your Pi accessible from the internet, forward ports:
  • Port 80 (HTTP) → 192.168.1.100
  • Port 443 (HTTPS) → 192.168.1.100
Log into your router’s admin page → “Port Forwarding / Virtual Server” → Add rules for TCP 80 and 443 pointing to your Pi’s static IP.

5. Install Nginx Web Server
On your Pi:

Code:

sudo apt update && sudo apt upgrade -ysudo apt install nginx -y
Check if it’s working:
Open http://192.168.1.100 from a browser inside your LAN. You should see the Nginx welcome page.

6. Install Certbot (Let’s Encrypt SSL)
Certbot will issue free SSL certificates for your domain.

Code:

sudo apt install certbot python3-certbot-nginx -y
Run Certbot for your FreeDNS domain:

Code:

sudo certbot --nginx -d myproject.raspberrydevice.com
Follow prompts. Certbot will:
  • Verify your domain (must resolve correctly via freedns.afraid.org)
  • Install SSL automatically into Nginx
  • Set up auto-renewal
Test renewal:

Code:

sudo certbot renew --dry-run
7. Test Your Website
Now visit:

Code:

https://myproject.raspberrydevice.com
You should see your Nginx default page, with a valid Let’s Encrypt SSL certificate.

8. Deploy Your Website
Replace Nginx’s default page with your project:

Code:

sudo nano /var/www/html/index.html
Add your HTML whatever content. Or set up /etc/nginx/sites-available/ with a custom server block for advanced setups.

9. Security & Tips
  • Keep your Pi updated:

    Code:

    sudo apt update && sudo apt upgrade -y
  • Use ufw firewall if needed:

    Code:

    sudo apt install ufwsudo ufw allow 'Nginx Full'sudo ufw enable
  • Consider limiting exposure by using Cloudflare as a reverse proxy if your ISP blocks port 80/443.
Done! You now have a Raspberry Pi 5 serving a website on myproject.raspberrydevice.com, secured with Let’s Encrypt, accessible from anywhere.

Statistics: Posted by verishare — Tue Sep 23, 2025 10:20 pm



Viewing all articles
Browse latest Browse all 8015

Trending Articles