-
Notifications
You must be signed in to change notification settings - Fork 4
Accessing from the Web
There are multiple ways to setup access from the web. I would suggest using a Dynamic DNS service as most likely you don't have a static IP address assigned from your ISP. But first lets test and make sure this all works!
Go to Whats My IP to find out the public IP address your ISP assigned you. It will be something weird that does not match your normal IP addressing scheme. Just point your browser at
https://<your ip address>
You will most likely be faced with a big warning stating that the site may not be secure. This is quite normal and expected. The reason being is that our SSL certificate is self signed, and not issued by a Certifying Authority. I will most likely be writing further instructions on how to add Lets Encrypt to HAProxy so we can use a legitimate signed SSL certificate. But for now a self signed certificate will do, we still get the encryption we are looking for. So click trust this site anyways or something of the like depending on your browser. This should bring you to a prompt asking you for the user name and password you setup for HAProxy. Once you successfully login you should see your OctoPi interface. FINALLY!!
A Dynamic DNS (DDNS) is a service that allows you to put a domain name to your IP address. And since your ISP most likely gives you a dynamic IP address the DDNS service usually has some sort of program that runs on your server that will check in and update your IP address as it dynamically changes. Plus, you get to type a web address instead of trying to remember your IP address every time you want to access Octopi.
There are many Dynamic DNS services available, some free and some paid. The choice is yours, but I chose Duck DNS for its simplicity and lack of needing to constantly check in to renew your lease on the sub-domain you choose (like no-ip.com forces you to do).
To start, navigate to Duck DNS and sign up for an account and create a domain of your choosing. For this example I will choose mastertork as my domain. You will notice at the top of your screen there will be a section that shows your "token". You will need this later in your setup, so leave this page open.
SSH into your OctoPi if you are not already and create a new folder named duck dns.
sudo mkdir duckdns
Then change directories to enter the duckdns folder.
cd duckdns
Then create a new file with nano
sudo nano duck.sh
Within nano copy and paste this text replacing [domain] with your domain (mastertork in my case) and [token] with the token duckdns provides you on your domains page.
echo url="https://www.duckdns.org/update?domains=[domain]&token=[token]&ip=" | curl -k -o ~/duckdns/duck.log -K -
Hit CTRL+X to exit y to save and ENTER to overwrite the existing duck.sh file.
Next you will need to modify the permissions of the duck.sh file with
sudo chmod 700 duck.sh
Finally, add we will tell the Raspberry Pi to run this script every 5 minutes to update our IP address with duckdns.org servers. Open chrontab
crontab -e
copy this text to the last line of crontab
*/5 * * * * ~/duckdns/duck.sh >/dev/null 2>&1
Now lets test the script to ensure all is working properly.
./duck.sh
now we can check the duck.log file we told it to create
cat duck.log
this should display any entries into the log.
Finish up with enabling the cron service
sudo service cron start
Then reboot and your FINISHED!!
sudo reboot -n
You should now be able to access your OctoPi from the web at https://<yoursubdomain>.duckdns.org.
The https:// is the important part, as that will automagically select port 443 like we want it to :)