Periodically, we experience issues accessing the domain through the Application Load Balancer. Several times a week, requests fail with a 502 error.
Example curl request:
Time: 2025-02-11-10:20:49, URL: https://example.com/health.html
* Host example.com:443 was resolved.
* IPv6: (none)
* IPv4: 10.169.8.127, 10.169.9.190, 10.169.10.72
* Trying 10.169.8.127:443...
* Connected to example.com (10.169.8.127) port 443
* ALPN: curl offers h2,http/1.1
} [5 bytes data]
* TLSv1.3 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.3 (IN), TLS handshake, Server hello (2):
{ [122 bytes data]
* TLSv1.3 (IN), TLS handshake, Encrypted Extensions (8):
{ [19 bytes data]
* TLSv1.3 (IN), TLS handshake, Certificate (11):
{ [4965 bytes data]
* TLSv1.3 (IN), TLS handshake, CERT verify (15):
{ [264 bytes data]
* TLSv1.3 (IN), TLS handshake, Finished (20):
{ [36 bytes data]
* TLSv1.3 (OUT), TLS change cipher, Change cipher spec (1):
} [1 bytes data]
* TLSv1.3 (OUT), TLS handshake, Finished (20):
} [36 bytes data]
* SSL connection using TLSv1.3 / TLS_AES_128_GCM_SHA256 / X25519 / RSASSA-PSS
* ALPN: server accepted h2
* Server certificate:
* subject: CN=example.com
* start date: Aug 16 00:00:00 2024 GMT
* expire date: Sep 14 23:59:59 2025 GMT
* issuer: C=US; O=Amazon; CN=Amazon RSA 2048 M02
* SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
* Certificate level 0: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
* Certificate level 1: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
* Certificate level 2: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
* Certificate level 3: Public key type RSA (2048/112 Bits/secBits), signed using sha256WithRSAEncryption
{ [5 bytes data]
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
{ [157 bytes data]
* using HTTP/2
* [HTTP/2] [1] OPENED stream for https://example.com/health.html
* [HTTP/2] [1] [:method: GET]
* [HTTP/2] [1] [:scheme: https]
* [HTTP/2] [1] [:authority: example.com]
* [HTTP/2] [1] [:path: /health.html]
* [HTTP/2] [1] [user-agent: curl/8.5.0]
* [HTTP/2] [1] [accept: */*]
} [5 bytes data]
> GET /health.html HTTP/2
> Host: example.com
> User-Agent: curl/8.5.0
> Accept: */*
>
{ [5 bytes data]
< HTTP/2 502
< server: awselb/2.0
< date: Tue, 11 Feb 2025 10:20:49 GMT
< content-type: text/html
< content-length: 122
<
{ [122 bytes data]
* Connection #0 to host example.com left intact
<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
</body>
</html>
http_code: 502
Domain Configuration
The domain is an alias for the ALB:
example.com is an alias for <alb_dns_name>.
<alb_dns_name> has address 10.169.10.72
<alb_dns_name> has address 10.169.8.127
<alb_dns_name> has address 10.169.9.190
Request Flow
When a request is made, it follows this path:
curl -> ALB -> K8s Ingress Nginx -> Pod
ALB Access Log Entry:
h2 2025-02-11T10:20:49.678019Z app/private/<some_id> 10.169.8.46:35932 10.169.18.139:32602 0.000 0.011 -1 502 - 42 192 "GET https://example.com:443/health.html HTTP/2.0" "curl/8.5.0" TLS_AES_128_GCM_SHA256 TLSv1.3 arn:aws:elasticloadbalancing:eu-central-1:<account_id>:targetgroup/alb/<alb_id> "Root=1-67ab2481-277e04655e050f1214b0e401" "example.com" "arn:aws:acm:eu-central-1:<account_id>:certificate/<certificate_id>" 0 2025-02-11T10:20:49.667000Z "forward" "-" "-" "10.169.18.139:32602" "-" "-" "-" TID_141e9eae38d93747bf092a191b52058a
Suspicious TCP Connection (tcpdump Analysis)
During this time, a suspicious TCP connection was observed:
The ALB responded with RST + ACK to FIN + ACK.
CleanShot 2025-02-12 at 14.44.11@2x
ALB Timeout Settings
HTTP client keepalive duration: 3600 seconds
Connection idle timeout: 60 seconds
Ingress Nginx Logs & Keepalive Settings
There is no record of this request in the Ingress Nginx logs, meaning the request never reached it.
Nginx keepalive settings:
upstream-keepalive-timeout: "10"
keepalive_timeout 75s; (Default)
Any ideas on what could be causing this issue?