Skip to content

Nlb associated to ecs service is not accessible with public ip address

0

I have an ecs service with a task running successfully. I can see in the logs the task comes up correctly and I can also see the calls from the nlb target group health check being made continuously. The nlb has an sg that is allowing inbound 443 calls and outbound 80 calls to the sg of my task service. The task service has a sg that allows all calls from the sg of the nlb and all outbound calls to any ip (I'll button these down once I get this working). The health check to my task's ip is successful and the logs look normal but I cannot access the public ip from a browser. Doing an nslookup on my domain shows the correct ip address.

13 Answers
3

The NLB config is using 172.31.23.46:444 as a Target. Note that it's sending the traffic to port 444, not 443.

Note: best practice is to allow clients to send traffic to your targets through your load balancer, but prevent them from sending traffic directly to your targets. Here is the article on how to do this: Security groups for your Network Load Balancer.

Also, you can use the SecurityGroupBlockedFlowCount_Inbound and SecurityGroupBlockedFlowCount_Outbound CloudWatch metrics to monitor the count of flows that are blocked by the load balancer security groups. Blocked traffic is not reflected in other metrics.

AWS
answered a year ago
2

This isn't a Security Group issue. It's a port mismatch. It looks like your NLB is configure to send traffic to port 444 on your target, instead of port 80.

The flow logs show traffic originating from 184.105.139.70 trying to connect to 172.31.23.46 on port 444. are you trying to use port 444 or 443 on your target server? above you state "My task does not use ssl, the nlb is handling the ssl and terminating it." and I see in the RA that you're entering port 80 as the destination. so, I would expect the see VPC Flow Logs show traffic destined for port 80.

Are you using client IP preservation?

You need to use a security group to allow traffic from the public internet to the NLB and from the NLB to the targets servers. (You can Only associate security groups with a Network Load Balancer when you create it. If you created the NLB without associating any security groups, you can't associate them later on.)

Best practice is to add a rule to the security groups associated with your targets that references the security group associated with your Network Load Balancer. This allows clients to send traffic to your targets through your load balancer, but prevents them from sending traffic directly to your targets. Referencing the security group associated with your Network Load Balancer in the security groups associated with your targets ensures that your targets accept traffic from your load balancer even if you enable client IP preservation for your load balancer.

AWS
answered a year ago
1

Do the route tables that are attached to the subnets hosting the NLB have the IPv4 default route 0.0.0.0/0 pointed at the VPC's IGW?

EXPERT
answered a year ago
1

Is it the TCP connection to port 443 that is failing, or are you perhaps receiving an error about the TLS certificate on the NLB when trying to connect with a web browser?

Is the NLB's security group configured on the NLB?

EXPERT
answered a year ago
  • No its timing out with ERR_CONNECTION_TIMED_OUT. As for the sg of the nlb the inbound is open to https on 443 to all ip. And the outbound is open to http and 80 (to the ecs service sg). My task does not use ssl, the nlb is handling the ssl and terminating it.

1

That shows the attempt arriving on port tcp/444, not tcp/443. What's the target for the listener on port 444? Which type of health check does the target group have and is it showing as healthy?

EXPERT
answered a year ago
  • Yes I noticed that too so I switched it to 443 and now it seems to connect although I get ERR_EMPTY_RESPONSE

0

I just ran the reachability analyzer on the igw to the private ip of the service and got this but I don't understand it Enter image description here

answered a year ago
  • What did you enter as input for the reachability analyser?

0

As input I entered this Enter image description here

answered a year ago
  • You should enter the public IP as the destination. The 172.31.* address is the internal IP within your VPC, but the packet arriving at the IGW will have a public IP as destination.

0

Ok I've run it again with the public ip as the destination. I guess its getting stopped at the first eni. Can you tell me what this means: ENI_SG_RULES_MISMATCH: None of the ingress rules in the following security groups apply: sg-0d44cd5165049a640

Enter image description here

answered a year ago
0

I tried many variations but this one which is open to all does not work either Enter image description here

answered a year ago
  • Can you run the reachability analyser with that rule in place? If it says that an inbound security group rule isn't present, then that screenshot simply can't be of the correct security group.

0

Yes the ra works with the all open sg for the nlb. What can I try next to get to my actual ecs service? Enter image description here

answered a year ago
  • Just tried the ra from the eni to the ig and that worked too but site is still just timing out

0

Could you show a screenshot of the inbound rules in sg-0d44cd5165049a640? You should have a rule permitting tcp/443 from 0.0.0.0/0 there.

EXPERT
answered a year ago
0

Just took a look at the logs from the nlb and get this: tls 2.0 2024-08-01T13:54:13 net/smnlb1/fabc7bd295e05943 7bce7635ca3f0674 184.105.139.70:36646 172.31.23.46:444 179 177 0 0 - arn:aws:acm:us-east-2:201558611471:certificate/eaf9dc1f-86ed-4840-be43-afa842d0fc09 - ECDHE-RSA-AES128-GCM-SHA256 tlsv12 - - - - - 2024-08-01T13:54:13 tls 2.0 2024-08-01T13:54:20 net/smnlb1/fabc7bd295e05943 7bce7635ca3f0674 184.105.139.70:36652 172.31.23.46:444 371 369 0 0 - arn:aws:acm:us-east-2:201558611471:certificate/eaf9dc1f-86ed-4840-be43-afa842d0fc09 - TLS_AES_128_GCM_SHA256 tlsv13 - - - - - 2024-08-01T13:54:20

answered a year ago
0

172.31.23.46 is the IP of the NLB, so it shouldn't be a target on any port. The target group should point to the IP 172.31.30.190 (or the corresponding instance ID) on the TCP (non-TLS) port 80 where the service is expected to listen.

EXPERT
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.