Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure Port Forwarding with Google Cloud Compute Engine for a Node.JS application

I'm trying to configure a port forwarding (port 80 to port 8080) for a Node.js application hosted on Google Cloud Compute Engine (Ubuntu and Nginx).

My ultimate goal is to have an url like "api.domain.com" showing exactly the same thing from "api.domain.com:8080" (:8080 is working actually).

But because it's a virtual server on Google platform, I'm not sure what kind of configuration I can do.

I tried these solutions without success (probably because it's a Google Cloud environment):

  1. Forwarding port 80 to 8080 using NGINX
  2. Best practices when running Node.js with port 80 (Ubuntu / Linode)

So two questions here:

1.Where I need to configure the port forwarding?

  • Directly in my Ubuntu instance with Nginx or Linux config files?
  • With gcloud command?
  • In a secret place in the UI of console.cloud.google.com?

2.What settings or configuration I need to save?

like image 478
probitaille Avatar asked Sep 13 '25 01:09

probitaille


1 Answers

One possibility is to use Google Cloud Load balancer. https://cloud.google.com/load-balancing/docs/

1) Create a backend service that listen on port 8080

2) Create a frontend service that listen on port 80

3) Then forward frontend trafic on this backend service

4) Bonus : You can create a ssl certificate auto managed by GCP https://cloud.google.com/load-balancing/docs/ssl-certificates#managed-certs

like image 54
Alexandre Avatar answered Sep 15 '25 14:09

Alexandre