Monday, November 22, 2021

Hosting a website on your local computer

If you want to host your website on your local Windows PC, you have to run a local web server:

  1. Setup IIS (it comes with Windows 10+). Use a port other than 80. Copy your website files to the folder that IIS recognizes. 
  2. Verify that on your browser, you can see your website when you type localhost:<Port> to the address bar.
  3. Add port to Windows Defender Firewall inbound rules.
  4. Add port to your modem so that the modem forwards traffic on that port to your local IP address. On my modem it is done in NAT Forwarding - Virtual Servers
  5. Verify that your website is online by turning off wifi on your mobile phone and typing http://<your global IP>:<Port> into your mobile browser address bar.
You cannot use https without a domain name for your local website because "In order to get a certificate for your website’s domain from Let’s Encrypt, you have to demonstrate control over the domain", i.e. you have to attach your IP address to a domain name.
Links related to SSL certificate: