My Raspberry PI

As stated in a previous post I’ve been strongly considering the possibilities for cloud based hosting, looking at AWS  and Heroku for Node.js apps. Those both have a free offering, but this is limited in its scalability, without starting to invoke charges. On top of Node, I need a MongoDb instance, a Git server, Test websites, and probably several other services I haven’t considered yet. For some reason I thought of my home ISP – I’m currently with Zen Internet, and whilst they squeeze uploads a little, it’s far more generous than many other providers, and they also provide me with a static IP. I considered using my Synology box, but this is currently set up on a bridged network away from my router, so there’d be lots of complicated IP routing to do. The model I have is the budget ‘J’-series and the processor’s speed leaves a lot to be desired. Then it occurred to me that I could achieve the same thing using a  Raspberry Pi.

I already have a Raspberry PI sat behind my TV with a pi specific version of XBMC running on it, serving films, photos and MP3s up to my TV. I’ve been very pleased with that solution. Well, the performance isn’t amazing, but it cost me about £30 all in, reusing an old SD card. The Raspberry Pi 2 is now out, featuring a vastly improved processor, and the price point hasn’t changed that much from the first model, so I ordered one. It arrived a couple of days later, and using an old phone charger and CAT5 cable, I connected it straight up to my Broadband router. I dived straight into using Raspbian which was dead easy to get set up. I guess I could have gone with Noobs, but something about the name put me off, not sure what. The thing is I didn’t have to do much complicated reading myself – the community using these devices is large and friendly and there are loads of helpful tutorials available. Within the hour I was able to connect through my local network onto the Pi by SSH from my Windows laptop. The most complicated bit of that was working out what IP address it had been assigned, for which I used  Angry IP scanner, which basically pings a range of ports and reports back if it finds any devices. At one point I was forced to reboot the Pi, and I couldn’t connect again – it had come back up with a new IP address, so I just used Angry IP scanner again, and found the new address. The next step was working out how to fix the device’s IP so I could reliably set up routing. The PI community proved invaluable: the top hit on Google for the search “raspberry pi fix ip” turned up this site with clear stepwise instructions for doing just that. I then installed Git server (not set up any repositories yet), then Node.js (using this tutorial). Most of these steps were not quite the same as doing the same thing on an average Linux distro, due to differences in processor architecture. The first real blocker I hit was setting up MongoDb, as this had to be compiled from scratch. This tutorial was absolutely excellent for this. the biggest problem being, my Network kept on flaking out during the installation forcing me to start again, which is highly inconvenient considering the build takes hours. At the end of this, for far less effort and time spent than I had anticipated, I was able to host my nascent pre-clinical solution, which uses the MEAN stack. I was extremely encouraged by the performance, and I guess the new processor is a genuine improvement on the original. About five minutes later I had also installed PM2, and launched the Node app on its own persistent thread.

The next step was externalising this site outside my home network – I had to navigate my router’s unintuitive port forwarding instructions. I think the router software is actually trying to make the job more intuitive by not mentioning port forwarding. It achieves the opposite! However I finally managed to navigate the sub-menus successfully, hop onto my phone, and navigate to the site using purely mobile data. The fact that I’m going to have to punch a specific hole out of the router from inside every time I want to expose another service is inconvenient, but probably better from a security point of view. I’m sure I’ll find a better way of doing this in due course. I also want to consider security in the wider context – just exposing services that I’ve hosted myself exposes my home network to hackers (not that there’s anything worth hacking). Cloud based providers are much better set up to deal with DOS attacks etc. I also need to consider backups and data persistence – should I take a snapshot of the image occasionally, or just back up specific services? It’s important not to host anything absolutely critical there, as after all, it is just a micro SD card, sat in a piece of flimsy circuitry on a window sill!