How do I enable http traffic for GCE instance templates?

前端 未结 5 646
攒了一身酷
攒了一身酷 2020-12-20 17:48

When creating an instance template in Google Compute Engine, how do I enable http traffic for instances created from the template?

I was thinking that providing an h

5条回答
  •  攒了一身酷
    2020-12-20 18:07

    One potential solution is to enable http traffic for all of your instances >in that project. To do so, from within GCE command line tools, run:

    gcloud compute firewall-rules create FIREWALL_RULE --allow tcp:80

    I try your command but it doesn't work because the command want the name of the instance:

    google130505_student@qwiklabs-gcp-286ef104ac93631b:~$ gcloud compute firewall-rules create FIREWALL_RULE --allow tcp:80
    Creating firewall...failed.
    ERROR: (gcloud.compute.firewall-rules.create) Could not fetch resource:
     - Invalid value for field 'resource.name': 'FIREWALL_RULE'. Must be a match of regex '(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)'
    google130505_student@qwiklabs-gcp-286ef104ac93631b:~$ gcloud compute firewall-rules create gclab2 --allow tcp:80
    Creating firewall.../Created [https://www.googleapis.com/compute/v1/projects/qwiklabs-gcp-286ef104ac93631b/global/firewalls/gclab2].
    Creating firewall...done.
    NAME    NETWORK  DIRECTION  PRIORITY  ALLOW   DENY
    gclab2  default  INGRESS    1000      tcp:80
    

    so the correct command is:

    gcloud compute firewall-rules create NAME_OF_YOUR_INSTANCE --allow tcp:80
    

提交回复
热议问题