NodeJs Lan application on RPi to google cloud platform to custom domain

October 18, 2021, at 2:40 PM

I have been able to set up my virtual machine on google cloud platform and am able to SSH into my RPi successfully using this tutorial:

Now I want to transfer HTTP data on port 8080 where my LAN application is hosted on the RPi instead of SSH data on port 22 to my virtual machine. How do i go about this and is it possible?

From there i plan on buying a domain to view my LAN app on the internet. I don't want to use services such as remoteit/zerotier to do this

Please help

Answer 1

For security reasons, I am recommending setting up a proxy between the Internet and your SSH server. You can skip steps #1 and #2 and use a port number above 1024 such as 8080. Never run the SSH server directly on port 80 as that requires privilege.


Install Apache or Nginx.


Set up a proxy in Apache/Nginx to forward connections on port 80 to port 8080.

Example configuration for Nginx:

server {
    listen 80;
    location / {
        proxy_set_header   X-Forwarded-For $remote_addr;
        proxy_set_header   Host $http_host;
        proxy_pass         "";


Configure the VM SSH server to allow port forwarding option AllowTcpForwarding.

Setup the tunnel to open port 8080 on the VM and forward to the listening port on your Raspberry Pi (example 9000).

Example SSH command to run on the raspberry Pi:

ssh -R 8080: <VM IP Address> <Your credentials>

Details. This command opens port 8080 on the public VM server and forwards traffic back to your system to port 9000.

Note: I did not test the SSH command, but this should be correct. There are many examples on the Internet such as link. This answer will help you understand how traffic is routed (forwarded).


Configure the application running on the Raspberry Pi to listen on port 9000 (example).

Summary, the client connects to VM port 80 which forwards to VM port 8080 which forwards over the SSH tunnel to the Raspberry Pi which has an application listening on port 9000.

Of course, you can change the port numbers, I used unique port numbers to prevent confusion.

MySQL: How to copy column of same table to another column with unix time convert

MySQL: How to copy column of same table to another column with unix time convert

I got my solution on SO on how to copy data from a column to another column but I need to convert the "from column" unix to the datetime columnColumnA is of type int and ColumnB is of type TIMESTAMP:

Multidimensional array replace with close range Javascript

Multidimensional array replace with close range Javascript

Let's say we have a List of ranges expressed in arrays with two elements [from, to]

bootstrap 5 bs-gutter-x throws off div&#39;s

bootstrap 5 bs-gutter-x throws off div's

My div alignment is being thrown off by the defaultrow class

Tkinter image not adding to text widget

Tkinter image not adding to text widget

I am trying to make text widget that get images from reddit then displaying it on a text widget, but for some reason, with no error, the image is not displaying on the widget