How to open a specific port such as 9090 in Google Compute Engine

前端 未结 8 2026
孤独总比滥情好
孤独总比滥情好 2020-11-22 13:15

I have 2 Google Compute Engine instances and I want to open port 9090 in both the instances. I think we need to add some firewall rules.

Can you tell me how can I

8条回答
  •  天涯浪人
    2020-11-22 13:18

    You'll need to add a firewall rule to open inbound access to tcp:9090 to your instances. If you have more than the two instances, and you only want to open 9090 to those two, you'll want to make sure that there is a tag that those two instances share. You can add or update tags via the console or the command-line; I'd recommend using the GUI for that if needed because it handles the read-modify-write cycle with setinstancetags.

    If you want to open port 9090 to all instances, you can create a firewall rule like:

    gcutil addfirewall allow-9090 --allowed=tcp:9090
    

    which will apply to all of your instances.

    If you only want to open port 9090 to the two instances that are serving your application, make sure that they have a tag like my-app, and then add a firewall like so:

    gcutil addfirewall my-app-9090 --allowed=tcp:9090 --target_tags=my-app
    

    You can read more about creating and managing firewalls in GCE here.

提交回复
热议问题