Tech User
Tech User

Reputation: 157

URL to access google cloud deployed rest API

I have developed a rest api and dockerized and deployed in google cloud VM (GCE). the REST api is running on port 8080. I am able to test the app using curl http://0.0.0.0:8080/api/myapi. I have also configured static external IP address for the instance. However I am not sure how I can access this rest api over internet.

Upvotes: 0

Views: 1945

Answers (1)

Lalo P
Lalo P

Reputation: 346

There's a list of things that you would need to check on this, I'll list all the steps for you to check and troubleshoot:

  1. You need to have a Firewall rule to allow traffic from the VM port, this is important because port 8080 is not open by default on the project Firewall.

  2. The VM should have an external IP address and a service listening on the desired port

  3. The container must have an IP and port open

Basically, outsider connections will go like this:

Browser:http://host-ip:8080 >> GCP project firewall >> Instance port 8080 >> container port 80 >> succesfull connection!

Meaning that 80 is the container's port and 8080 is the port mapped on the host VM in GCP.

Troubleshooting Steps (The example was performed with nginx which by default has the port 80/tcp open and was mapped to the port 8081 on the VM):

It will be useful to know your error message, but I suggest you to follow the above steps to validate if used ports are mapped and opened in the container and in the VM instance.

Upvotes: 1

Related Questions