SSH tunnels are useful to cross insecure networks, providing end-to-end encryption when connecting two end points that seat on distinct networks.
A far as I can tell (thanks to comments), what you have is:
A local host-A: your localhost
, on your local network (likely behind firewall/NAT)
A publicly reachable host-B: the aws
server
A non-publicly reachable host-C: on the restricted remote network (likely behind firewall/NAT)
A non-publicly reachable host-D: the one you refer to as deviceIP
, that listens on port 80
and is on the remote restricted network
If you want to connect your host A to host D, letting your browser reach it on port 80
, you need:
A tunnel from host-A to host-B, that:
Lets host-A listen on port 8080
Sends traffic from that port through the tunnel
On host-B (aws
), redirects the traffic coming from the tunnel to the local (i.e. on host-B) port 15872
(I took it from your comments; you can choose any available port; just make sure to use the same one in all commands)
# Execute on host-A
$ ssh -L 8080:localhost:15872 user@host-B
A tunnel from host-C to host-B, that:
Lets host-B listen on port 15872
Sends traffic from that port through the tunnel
On host-C (your Linux server), redirects that traffic to port 80
on host-D
# Execute on host-C
$ ssh -R *:15872:host-D:80 user@host-B
This way, requests made to host-A on port 8080
will be tunneled to host-B, redirected to port 15872
on the same host-B, tunneled to host-C and redirected on host-C to port 80
of host-D.