Ninethousand
Ninethousand

Reputation: 535

Google Compute Engine: how to make requests from outside?

I'm completely new to Google Cloud and Google Compute Engine. I have a VM instance set up in GCE, and would like to make requests to it.

Inside the instance, I have a basic Nginx running (of which I admittedly have also a very limited understanding), with the following configuration:

http {
  server {
    listen 80 default_server;
    return 200 hello;
  }
}

If I access it from inside the instance through the google cloud console, for instance with a curl, it does work, but I don't know how to access it from outside.

In the list of Compute Engine VM instances, the instance has an external IP associated (let's say for example 35.204.94.110), but requests to http://35.204.94.110:80 don't get a response.

How can I do it to access the instance from the outside?

Upvotes: 1

Views: 3166

Answers (2)

user835611
user835611

Reputation: 2376

Looks like you don't have http access enabled. Check the firewall rules and add the default-allow-http label to your GCE instance.

Upvotes: 1

Jason
Jason

Reputation: 638

I would make sure that HTTP access is enabled on the VM instance. When creating a VM instance, there are two check boxex:

  • Allow HTTP traffic
  • Allow HTTPS traffic

If the box is unchecked for “Allow HTTP traffic”, then this would explain the behavior. Go into your console and click on the affected VM instance and then scroll down until you see if the “Allow HTTP traffic” box is checked. If not, click Edit, checkmark the box to allow HTTP traffic and then save the changes. You should now be able to load the page externally.

I tested this myself by just installing and enabling nginx on a VM instance. If I disable “Allow HTTP traffic” the page does not load. When it is enabled, I am able to load the default web page of nginx successfully.

Upvotes: 3

Related Questions