Homelab Web Server
Why run a homelab webserver?
- Spin up dev and test environments quickly eg for different projects I need versions of .NET, Python etc.
- Leave them up and not incur cloud charges
- Run a production website cheaper than running on the cloud
In this article I’m going to do the simplest possible thing
- Ubuntu Server on bare metal (no virtualisation)
- Nginx webserver
- No DMZ
- Dynamic DNS to keep a track of changing public IP address
- Wire up own domain name
Connection
I’ve got a 48 MBits/s / 11 MBits/s Plusnet connection.
I’m using the standard free Plusnet Hub One router.
Ubuntu Server
Am using a 4 Core (8 hyperthreaded) Intel i5-6600 at 3.3GHz with 16GB of RAM and have a new 1TB M.2 SSD in it.
To test the concept I put on Ubuntu Server 20.04.3 LTS including installing SSH Server.
I used https://www.balena.io/etcher/ to burn the ISO onto an 8GB USB drive (my motherboard didn’t like the 16GB Kingston).
Can connect to the new Ubuntu machine called silver, from ssh on WSL2.
then installed Nginx:
sudo apt-get install nginx -y
As an aside I installed Ubuntu Server using the wireless network adapter which caused confusion as I had to disable the adapter when I went to wired. It was noticably slower on wireless.
https://linuxconfig.org/ubuntu-20-04-connect-to-wifi-from-command-line
# networking config files (comment out the wireles one)
cd /etc/netplan/
# show networking
# 192.168.1.139 local network
ip a
Can hit the webserver locally from my Windows Machine. http://silver
works as well. DNS resolution is handled by the router as all on DHCP.
External Networking
Allowing port 80 to the home server which is called silver. Nginx is running (as we have proven) so should answer on port 80.
Finding out my public IP using google.
Using 4G connection from my phone to hit webserver externally - it worked!
Dynamic DNS
https://www.noip.com/ As I’m not on a static IP address I need a free service like to keep track of what is my current IP.
After signing up on their website, my router can update their service when it’s public IP changes. Very handy.
I can now access my webserver from this domain name which I chose from https://noip.com
To use a domain I own, I can use an Alias record.
Conclusion
We have a working website live on the internet.
Next steps are
- Be more secure (DMZ / different subnet than main home network)
- Test SSL works ie port 443 (it works fine)
- Use a hypervisor so can have many VM’s on the box (article coming soon)
- Transfer over a production website and turn off Azure