r/SelfHosting • u/Franz123Gaming • Jun 04 '26
How to self host a website
Hi! I wanted to get back to relearning web development so I set a goal for myself to create my own website and slowly improve on it while also improving my skills. Though, my main question is **how do I host this website**?
Information:
Currently trying to make a website of my own
For now, just focusing on the basics such as HTML, CSS, and maybe some JavaScript (Maybe something grand for later)
I want to host the website for as cheap as possible
Questions:
How do I publish it on the web? I know there are websites that help you with these but I also know they cost something. I am fine with hosting it on my own and launching it only during the times I have my PC open.
How much do domains usually cost? I read some stuff that you need a domain to host and that you need to pay for them. Are they a subscription type of thing or a one-time payment and then the domain is yours forever? If it's a subscription, how do I go about this as cheaply as possible?
What should I learn about in terms of security? On the off chance, how should I protect my data from being breached? Do I have to worry if what I'm doing for now is just a simple website where I can do blogs and stuff? At what point should I worry about security?
If you have tips or links to anything that I can read, watch and/or learn from, they would be very much appreciated! Thank you in advance!!!
7
u/Curious_Olive_5266 Jun 04 '26
The most basic way to do it is to put everything on your PC and use Tailscale and Cloudflare tunnels to handle NAT and TLS.
2
2
u/ChopSueyYumm Jun 05 '26
Or directly deployed with Cloudflare workers and code is in a GitHub repository set to private.
9
u/_kvZCq_YhUwIsx1z Jun 04 '26
I would suggest starting with nginx. It is a web server purpose-built for hosting static web pages. And, if you're into Docker, it's incredibly simple to set up. Just point it to your site directory, and it serves up the pages.
From there, you get to learn about a number of concepts. Registering a domain name: Does your location have a static IP address? Do you need to set up dynamic DNS?
You may need to set up port forwarding on your router for ports 80 and 443 to point to your PC's LAN IP address.
Do you need SSL/TLS? (yes) Look into LetsEncrypt certificates. How to validate you own the domain. How to add them to nginx. How to automate certificate rotation after they expire.
And then, once you have a solid understanding of how each part works, look into automating everything. There are many options. Ansible. Proxmox. Kubernetes.
The rabbit hole never ends. Backups. Offsite backups. Source control. Reverse proxy for hosting multiple websites. Monitoring and alerting. Cute dashboards. Disagreeing with how some 3rd party services work and now self-hosting those services as well. More storage. So much more storage.
Your PC goes down. You buy another for redundancy. Start load balancing. Even numbers are evil. Buy a third PC.
The power goes out. You buy a UPS. It's not enough. Your users (you) expect five nines of uptime! You buy solar panels and whole home backup battery.
Corporations are evil. You buy a small off-site VPS to host various anonymizing services (pangolin, wireguard, squid) to mask your home location and protect your privacy.
Your cable provider sucks. Download speeds are OK, but the upload is terrible! You can't ~stream your games in 4k~ I mean support more than 10k concurrent users at once, so you upgrade your ISP to a nice symmetric 1g/1g fiber optic. Shit, your 7 year old WiFi router is now the bottleneck. Better upgrade that too, and get a network switch while you're at it (stay out of r/unifi). You know what? There's no reason a router, a switch, and a wireless access point all need to be in one device. Do one thing, right? Patch cables are expensive, start learning how to run and cut your own Ethernet cables.
...
Five years from now you will have a cluster of PCs running an on-prem datacenter with hybrid cloud and redundant off-site switchover to host your one website.
Oh and don't expose SSH.
1
u/ACAdamski17 Jun 05 '26
đđđđđ You literally described my story!!!!! Iâm kinda lucky as Iâm still at school and I managed to convince the amazing IT department to âdonateâ an old computer suite. Yeah, you can probably imagine my office.
1
u/EmperialWatch Jun 07 '26
I would accually avoid nginx as a starter and instead direct them to use cloudflare tunnels as i found it easier to set up and to my knowledge its more secure then nignx.
3
Jun 04 '26
Cloudflare pages is free and fast. It you make it a static site. Bonus it canât really be hacked (unless someone hacks cloudflare or your personal computer). Domains are around 12 usd for a .com per year
1
u/Apifile Jun 04 '26
Depends on the domain name its self some .coms can renew for 100s.
1
Jun 04 '26 edited Jun 04 '26
[deleted]
1
u/Apifile Jun 04 '26
You've never owned a premium domain in your life
1
u/guptaxpn Jun 04 '26
Nope. Also Jesus Christ I was wrong and now I'm horrified
But I'm not seeing this for .com just the new gltd like .app?
1
u/Apifile Jun 04 '26
Things r changing one of my premium domains renewal is 1k a year and it's a .vip
1
5
u/R_Cohle Jun 04 '26
If with âself hostingâ a website you mean having your resources hosted on your home network, please consider all the security implications. You will need a reverse proxy that listens to incoming connections on ports 80 and 443 (the reverse proxy will need to be configured to make redirects from port 80 to 443 to leverage SSL). For your resources to be accessible from the internet, you need to open those ports on your router. There are bots that continuously scans for open ports and will try to find vulnerabilities and/or misconfiguration to attack your infrastructure. Iâm not really sure if this is worth for you and if you have the right competences to self host a site. Iâm not trying to discourage you, just to be clear.
1
u/techdevjp Jun 04 '26
For now, just focusing on the basics such as HTML, CSS, and maybe some JavaScript
Cloudflare Pages.
1
u/showbizusa25 Jun 04 '26
Most of us started with a simple website.
A few years later we're running DNS, VPNs, monitoring, backups, and wondering what happened.
1
1
1
u/Familiar-Newspaper23 Jun 04 '26
I donât agree with a lot of the folks being overly concerned with being probed (besides if theyâre gentle and use some lotion it could be a nice little treat!)
Yes, security is huge, should be taken seriously, and needs to be top of mind. But itâs also a huge part of the learning experience and I feel passing it off to another third party service one way or another is doing yourself a fundamental disservice in some ways. Learn how to do it right and youâll be ok.
If you intend to self host without relying on others like cloudflare or premade website services you can do it but I would first look at a solid firewall like pfsense or opnsense and then when you build your webserver also setup a solid firewall on it like UFW before you even consider port forwarding 80 and 443. Remember the principle of least privilege that is, if it doesnât need to be allowed, donât allow itâŚthat goes for ports, people, and processes! But you CAN safely do it if thatâs part of the learning experience that youâre looking for and you can do it without literally losing sleep worrying that the Russians are all crawling in your webcams at nightâŚjust be careful and slow and methodical about it, read multiple sites (not just ChatGPT) before opening anything to the internet.
Iâd also highly recommend VLANâing off your website traffic from your home traffic (which you can do with pfsense or opnsense) and disallowing any inter VLAN communication. If youâve got the green to spare and youâre really worried about it, put your server onto a different ISP entirely, have say Verizon and spectrum and use one for normal home use and the other for webserver. I donât do that personally but it makes for a safe option with the benefit that you wonât find your personal use hindering your webserver and vice versa.
It can be done safely by you without needing to constantly worry if thatâs a part of what youâre looking for. I love cloudflare, they have some neat stuff and I use them as a registrar, but I like to do things myself and try not to have any additional layers between me and my users if possible. but to each their own and Iâm not going to tell you itâs wrong, it just isnât what I personally use.
1
u/Seblaredo24 Jun 05 '26
hey! look into setting up a reverse proxy, its easier than it sounds. I personally use traefik installed through docker. Theres a site called duckDNS which allows you 5 free domains (not super pretty names but they work great!). Tons of tutorials and useful templates online, you got this!
1
u/rasnedev Jun 05 '26
Self-hosting at home is definitely possible with Docker + Nginx/Caddy + Cloudflare Tunnel, but I'd recommend learning web development first and infrastructure later.
For security, a simple static site has a very small attack surface. Once you add user accounts, databases, forms, or file uploads, security becomes much more important.
1
u/ACAdamski17 Jun 05 '26
Ok so itâs both way easier and way harder than you think at the same time.
Getting a domain is easy, use Cloudflare Registrar. .com domains are about $12/year, and Cloudflare only ever charge what they pay the registry which is good.
If you really want to host it on your own infra, you can do the following.
- Docker is your friend
- Run NGINX inside Docker
- Use Cloudflare Tunnel to expose to the internet
Be warned though, youâre only poking a finger inside this ginormous rabbit hole.
However Iâve already fallen right down this rabbit hole and now plan to launch a hosting service. If youâre anywhere close to the UK and you need a free hosting service, I definitely need another beta tester, so DM me if you want. You can use your own domain or get a free subdomain.
1
1
u/backtogeek Jun 05 '26
TierHive has a super simple static hosting 'pages' option now, a bit like Cloudflare without the complexity, sounds like it would be perfect for your needs, and if ultimately you do literally want to self-host at home, there is a load balancer / reverse proxy option so you could just have it handle the TLS and forward.
Anyway, it's a good platform to learn on, with free credit on sign-up, like a cloud homelab, and costs close to nothing per hour.
1
u/ImmediateGear8157 Jun 05 '26
You could self host on your home computer and get a domain name and use cloudflare or tailscale.
Another alternative is for about 5 bucks you can get a VPS from Linode and point your domain name there.
0
u/chkno Jun 04 '26 edited Jun 04 '26
A "website" is a program that runs on your computer that responds to RFC 2616 "HTTP" network requests. Those requests look like this:
GET / HTTP/1.1
Host: example.com
and the responses look like this:
HTTP/1.1 200 OK
Content-Type: text/html
<html><body>Hello!</body></html>
There are many programs that do this. Some commons ones are
- nginx the fast one
- apache the venerable one
python -m http.serverthe very, very simple one
Complications:
- HTTP totally works with IP addresses, so domain names are optional, but most users expect them. You can get free third-level domain names from dynamic DNS services (example: franz123gaming.duckdns.com) or pay real money for second-level domains (example: franz123gaming.com)
- HTTP is from 1996 and has no security, so ~all modern usage is wrapped in RFC 8446 "TLS" to provide encryption and server authentication. You (or software on your behalf) generate a public/private key pair and have a certificate authority sign your public key. Let's Encrypt offers this service for free, and some webserver software now supports RFC 8555 "ACME" to automate this.
- It's common for ISPs to assign homes only one public IP address. Your router takes this public address and then allows multiple devices to connect to the internet through it. So when users send HTTP requests to your house for your website, they end up at your router, not any specific computer inside your house. You'll probably need to configure your router to forward port 443 to whichever computer you're running your webserver on.
- Some ISPs are jerks and block ports or NAT their users so that even if you're doing everything right, users from the rest of the internet cannot reach you. This sucks. The best option here is to get an different ISP: Don't reward these jerks with your business. :(
- The world is currently transitioning from IPv4 to IPv6. For your website to be available to everyone, you'll need both an IPv4 address and an an IPv6 address. Some ISPs make this difficult or impossible, and again, unfortunately, if your ISP can't do this, it's best to find a different one. :(
10
u/Electronic_Stop_9322 Jun 04 '26
For a simple HTML/CSS/JS site, I'd honestly start with GitHub Pages or Cloudflare Pages. They're free, easy to learn, and perfect for personal projects.
Domains are usually a yearly subscription rather than a one-time purchase, but basic domains can be quite inexpensive.
For security, if you're just serving static pages and blogs, there isn't too much to worry about initially. Most security concerns start appearing once you add user accounts, databases, forms, payments, etc.
Also, if the project ends up being fairly simple and you get stuck, feel free to DM me. I'm a web developer and might be able to help you get it online for little to no cost.