I have linux-based device (let's say a Raspberry Pi) that hosts a HTTP server. This device regularly changes WiFi access point and is often not publicly accessible due to NAT and/or firewall.
I want to setup a reverse ssh tunnel using a publicly available server (rpi.example.com
below) such that rpi behind NAT
establish a tunnel to rpi.example.com
at boot. rpi.example.com
will then forward any HTTP request to the rpi behind NAT
.
Sequence diagram:
HTTP client rpi.example.com rpi behind NAT
+ + +
| | ssh -R |
| | <-----------------+
| GET /temp | |
+-----------------> | |
| +-----------------> |
| | [SSH tunnel] |
| | <-----------------|
| HTTP/1.1 200 OK | |
| <-----------------+ |
| | |
How to setup a reverse SSH tunnel like that? Is there a better alternative?