In this day and age creating a website and having it hosted is pretty cheap, yet there are still those, myself included, who would rather host their own website and potentially other services on their home network. I have been doing this for years off and on and for non-production sites, such as development sites, or even personal sites I believe this to be a cost effective way to go.
Below are a few details on how I have accomplished this using cheap tech and at very little cost, outside of what I am already paying for my current internet connection. I will note that the speed with which your site is rendered will depend largely on your internet connection, hardware on which you host, the amount of graphics, and the general functionality of the site you are hosting.
I recently purchased the domain dmccarthy.io because I am a vain person or perhaps I have some subconcious goal in mind for the domain for future use. I did not want to pay for hosting on this site for which I am still uncertain what I will do with, so with my new RaspberryPi 2, the purchased domain I set about trying to find an expensive way to accomplish this hosting.
In order to have your domain pointed to an internal network the first step will be to have the authoritative DNS server point all traffic for the domain to your ISP assigned IP. I did not want to overload the Pi with a lot of extraneous services outside of serving up the web pages for the site, so I searched the Google machine for a free service to be the authoratative answer. I found cloudns.net. I signed up for a free account with ClouDNS and created the records I would need for the web server.
With the ClouDNS entries complete I then went to my domain registrar, in this case, GoDaddy, and modified the DNS servers for dmccarthy.io to point the servers specified by ClouDNS. DNS changes can take some time to propogate out to all the Interwebs, however, these changes happened quickly for me and the web site resolved to my ISP assigned IP immediately.
Now on your router all you need to do is create a port forwarding rule to forward traffic on port 80 of the public IP address to the port, likely 80, on which you are running your web server. Your web server can be Apache, Node, Nginx, even IIS if you so desire. With the forwarding rule in place you are done. Kind of. Most ISPs assign a dynamic IP, that is an IP that changes or can change as your lease on the DHCP assigned IP expires, your router reboots, or for a number of various reasons. ClouDNS offers a solution for the ever changing IP address. That is Dynamic DNS. You'll notice the blue arrows on the graphic above. These blue arrows will send you to a page that provides a URL that when opened from the web server, will cause the IP address to be changed to that from which the URL is opened. ClouDNS offers several different scripts which, on a Linux based machine, can be scheduled to run periodically via a crontab entry.
For me, I run several websites on my internal network, and as such, a simple port 80 forward rule just doesn't do the trick. I have previously written about setting up a Node.JS Server to act as a reverse proxy. While that worked to some extent, I have settled on using Nginx as my web server on the Pi and have also configured Nginx to act as a reverse proxy for the other sites. I will update this article once I have completed the write-up on Nginx as a reverse proxy.