Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.8k views
in Technique[技术] by (71.8m points)

amazon web services - Cant connect to internet facing ELB from instance in VPC

I have a V2 ELB that is internet facing. It routes requests to instances in VPC just fine when I connect to it from my laptop. However when I try to connect to it from another instance inside the same VPC the Security Group firewall rules block the connection.

The only way I can get the instances in VPC to connec to the ELB is by opening the https port (443) to the world.

What am I doing wrong?

The ELB (https://elb.domain.com) has the following attrs:

  • Internet facing, V2 (not classic ELB)
  • VPC: vpc-aaa
  • AZs: subnet-a,subnet-b
  • Listeners: 443 -> 8080 instance port
  • source security group: my-vpc-elb, with inbound rules:
    • 443, source: 1.2.3.170/32 (my laptop IP)
    • 443, source: sg-a (the name of the sg that my vpc instance, that cant connect, is in)
    • 443, source <CIDR of vpc-aaa, 1.2.0.0/16>

From my laptop I can put in https://elb.domain.com and things work fine.

I now have another instance with the following attrs that can NOT connect to https://elb.domain.com:

  • Subnet ID: subnet-a
  • Security Group: sg-a

Why does the ELB Security group rule of 443, source: sg-a not allow the connection? Why does it only work when I allow inbound "All traffic" on 443 in the ELB security group?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Instances in VPC, when connecting to a public-facing load balancer will always exit the VPC and come back in from a public IP. In this scenario there is no way to lock inbound traffic by security group.

If the VPC instances trying to connect to the ELB do not need public IPs, you can simply setup an inbound rule on your ELB that only allows the source to be that of your VPC NAT Gateway(s).

If they do require public IPs, your are forced to specify AWS VPC public IP range, or if you use EIP you can specify the EIP(s).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...