Opscraft
HTTP & status codes · Lesson 7 of 9 · 3 min read

Kubernetes ingress and AWS service specifics

Ingress returns 404 for a path that should work

Check the host matches the request's Host header exactly; path and pathType (Prefix vs Exact — /api Exact won't match /api/orders); ingressClassName (wrong class → no controller serves it → default backend 404); the backend Service name and port; rewrite annotations (nginx.ingress.kubernetes.io/rewrite-target) changing the path the app receives; and whether another Ingress claims the same host/path.

S3 returns 403 for a static site

  • The bucket policy / CloudFront Origin Access Control (OAC) doesn't allow the reader.
  • The object doesn't exist and the requester lacks s3:ListBucket — S3 returns 403 instead of 404 to avoid revealing whether objects exist.
  • Block Public Access enabled while trying to use a public website endpoint.
  • KMS-encrypted objects without kms:Decrypt for the reader.

CloudFront 403/404 on SPA routes

Single-page apps (React/Angular) serve routes like /dashboard from index.html. S3 has no /dashboard object → 403/404. Fix: CloudFront custom error responses mapping 403 and 404 to /index.html with response code 200 (or a CloudFront Function for URL rewrites).

API Gateway quirks

  • {"message":"Missing Authentication Token"} 403 — often simply a wrong path or method, not auth.
  • 429 — stage/method throttling or usage plan limits.
  • 502 — Lambda integration returned a malformed response (wrong proxy response shape) or errored.
  • 504 — integration timeout (29 s default for REST APIs).
  • 401 only through the gateway, not direct — authorizer configuration, or the Authorization header isn't forwarded/mapped.

Health checks and redirects

If the app redirects HTTP to HTTPS (or / to /login), an ALB/ingress health check expecting 200 marks every target unhealthy → 503s for users. Point health checks at a dedicated path that returns 200 (e.g. /healthz), or configure the success codes (200-399).

Liveness vs readiness endpoints

  • Liveness should return 200 as long as the process is alive and not deadlocked — don't fail it because a dependency is down (that just restarts healthy pods in a loop).
  • Readiness should fail when the pod can't serve traffic (dependency it truly needs unavailable, warming up), removing it from load balancing without restarting it.
Enlarge diagramLiveness probeReadiness probeFails only if the process is stuck or deadlockedFailure → the container is restartedNever fail it because a dependency is downFails while the pod cannot serve (warming up,needed dependency down)Failure → removed from load balancing, notrestartedComes back automatically when it passes
Figure 1. Liveness asks "should this container be restarted?"; readiness asks "should it get traffic right now?". Mixing them up causes restarts during outages.
Swipe sideways to see all of it, or tap to open it full screen.