Last year we talked about setting up simple home automation. Building off of that, let’s talk about setting up a web server on the SBC to share data on the world wide web.
Once you’ve uploaded your program, compiled it and tested it by going to your local site (for example, http://mcflysbc.local:8000), you’ll need to forward the ports through your router so you can see it anywhere on the web, and you’ll probably want to get your own domain name so you don’t have to remember a scramble of numbers.
Before launching the website, you’ll probably want to tune your program to show only the data that you want anyone to see. Go back to the simple home automation guide to get the details on editing the code. For me, I replaced the relay switch with an LED. I still want it to be interactive, but not have my room lights turn on and off with wild abandon.
To find you SBC's IP address Log onto your SBC’s web configuration and go to the Network page. The IP Address will be obviously displayed there.
First you need to set up port forwarding on your router. Open your router’s settings page. This can be accessed through one of the following addresses: http://192.168.1.1, http://192.168.0.1, http://192.168.2.1, or an address specified in your router’s user manual.
Find the port forwarding. Each router is different so it’s hard to say where it’ll be put for your device (commonly under “Applications and Gaming” or “Advanced Settings”; You can find your router’s name for it here). Once you find it, enable a new port forward. Set the internal start port and end port to 8000; the external start port and end port to 80; protocol is TCP; and the IP address will be the IP address of your SBC.
You can purchase a domain from sites like Hover, Namecheap, Gandi, Dreamhost, Name.com, or GoDaddy. If you don’t want to pay, and don’t mind an extension on your domain (like ddns.com) then use a service like No-IP. Set up the domain as a DNS host and give the IP address of the SBC that you found in the last step.
Now you can go to your URL and monitor your home from wherever you are.