简体   繁体   中英

How to make two ec2 instances connected with each other internally

I have two ec2 instances on one region and one of the instance is running a sever on port 8080 . The security setting for these instances is to block all port except 22. How can I let one instance open port 8080 only for the other ec2 instance? I know how to set the inbound port number in security group setting but it will make 8080 to be public. How can I enable the port only for one particular ec2 instance?

Ok, so you have server running on instance, let's say, i-ssssss . Client is running on instance i-cccccc . And you want instance i-cccccc to access port 8080 of i-ssssss . Your actions are:

  1. Create security group sg-cccccc
  2. Create security group sg-ssssss
  3. Create inbound rule for sg-ssssss where:
    • Type is Custom TCP Rule
    • Port Range is 8080
    • Source is sg-cccccc (yes, you can specify security group as inbound rule source)
  4. Attach sg-cccccc to instance i-cccccc
  5. Attach sg-ssssss to instance i-ssssss

There are other options and nuances. For example you could have only one security group attached to both instances. In this case all instances having this sg attached would be able to open needed port for all other instances in this sg.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM