I want to build an application for Raspberry Pi (C++, Boost, OpenSSL) that handles file download/upload requests (and other custom actions). The RPi has an external HDD connected to it (through USB). Let's call it simply Storage (RPi + HDD).
I have a public server that I can configure for any need. The problem is that the Storage is behind a router that I don't have access to configure (port forwarding is excluded), so, the public server cannot connect to Stroage directly.
Programmatically, what is the optimal way to communicate between a client (web browser / mobile application) and Storage through the public server? A simple use case is this: I want to download a file from Storage to my phone over the internet.
I can think of two possible solutions:
- Maintain a tunnel open between public server and Storage. Is this scalable for multiple Storages (assuming that the public server will serve many of them in the future)?
- The Storage pings every let's say 3 seconds the public server (more like announces server that it is online) and if the public server has a request from a client, then a full connection will be established (client <-> public server <-> Storage) and the file download/upload request will be handled normally.
How can I implement this (third party tools like Weaved is excluded) and what other possibilities are there? Also, are the two alternative I described above even viable?
The overall sistem architecture looks like the one below.
I know that this is a more general question, but I don't know how to approach my particular case.