debugging
Debugging Cmd Example

📘 Table of Contents

  1. Overview
  2. Quick Reference Table
  3. Debugging by Category
  4. Application-Level Debugging
  5. Infrastructure-Level Debugging
  6. Best Practices
  7. Common curl -vk Scenarios
  8. Command Summary

🧩 Overview

Use curl -vk and curl -I to quickly understand where the request is failing:

LayerWhat It Tells You
ClientTLS, DNS, headers
ALB/WAFBlocking, routing, redirect issues
IngressHost/path rule mismatch
ServiceRouting / ports issues
Pod/AppLogic errors, crashes

Quick Reference Table

CategoryCode RangeMeaningTools
1xx100–199Informationalcurl -v, logs
2xx200–299Successcurl, application logs
3xx300–399Redirectcurl -I, check Location header
4xx400–499Client ErrorWAF, auth, ingress
5xx500–599Server Errorbackend, containers, infra

🧠 Debugging by Category

🟦 1xx — Informational

curl -v https://{{TEST_DOMAIN}}

For WebSockets:

curl -i -H "Connection: Upgrade" -H "Upgrade: websocket" https://{{TEST_DOMAIN}}

🟩 2xx — Success

Check details:

curl -i https://{{TEST_DOMAIN}}/api/resource

Minimal code check:

curl -s -o /dev/null -w "%{http_code}\n" https://{{TEST_DOMAIN}}

🟨 3xx — Redirect

Check redirect chain:

curl -IL https://{{TEST_DOMAIN}}

Check HTTP → HTTPS rule:

curl -I http://{{TEST_DOMAIN}}

🟥 4xx — Client Errors

400 Bad Request

curl -v -X POST -H "Content-Type: application/json" -d '{"broken":123' https://{{TEST_DOMAIN}}/api

401 Unauthorized

curl -v -H "Authorization: Bearer {{TOKEN}}" https://{{TEST_DOMAIN}}/secure

403 Forbidden

curl -v https://{{TEST_DOMAIN}}

Check WAF, IP allow list, RBAC.

404 Not Found

curl -I https://{{TEST_DOMAIN}}/wrongpath

405 Method Not Allowed

curl -X PUT https://{{TEST_DOMAIN}}/api/resource

408 Timeout

curl -m 60 -v https://{{TEST_DOMAIN}}

5xx — Server Errors

500 Internal Server Error

curl -v https://{{TEST_DOMAIN}}
kubectl logs {{POD_NAME}} | tail -n 50

502 Bad Gateway

Check via bypass:

curl -vk https://{{ALB_DNS_NAME}}

503 Service Unavailable

kubectl get pods -A | grep {{SERVICE_NAME}}

504 Gateway Timeout

Backend too slow:

curl -m 5 -v https://{{TEST_DOMAIN}}

🧱 Application-Level Debugging

Logs:

tail -f /var/log/{{APP_NAME}}.log

Environment:

printenv | grep {{APP_NAME}}

☁️ Infrastructure-Level Debugging

Pods:

kubectl get pods -A
kubectl logs {{POD_NAME}} --tail=100

DNS:

dig {{TEST_DOMAIN}}

Security Groups:

aws ec2 describe-security-groups --region {{AWS_REGION}}

🧩 Best Practices (Always start here)

curl -v https://{{SERVICE_DOMAIN_UAT}}

Bypass DNS:

curl -k -H "Host: {{SERVICE_DOMAIN_UAT}}" https://{{ALB_DNS_NAME}}

🌐 cURL Deep Debug: Host Header Test

Use when DNS is wrong or propagation pending:

curl -vk -H "Host: {{SERVICE_DOMAIN}}" https://{{ALB_DNS_NAME}}

🔍 Breakdown

FlagMeaning
-kIgnore SSL verification
-H "Host: {{SERVICE_DOMAIN}}"Overrides Host header
https://{{ALB_DNS_NAME}}Connect directly to ALB

🧠 Expected Outputs & Meanings

OutputMeaningFix
200 OKAll good
301/302Redirectcheck base URLs
400malformed requestJSON, headers
403WAF blockcheck Web ACL
404ingress path missingupdate Ingress rules
502ALB can't talk to backendcheck target group
503no healthy podsfix deployment
504backend slowfix DB/API slowness

🧾 Example Response — Sanitized

200 OK

* Connected to {{ALB_DNS_NAME}}
> Host: {{SERVICE_DOMAIN}}
< HTTP/2 200
< content-type: application/json

403 Forbidden (WAF)

< HTTP/1.1 403 Forbidden
< x-amzn-waf-action: BLOCK

404 Ingress Misconfiguration

< HTTP/1.1 404 Not Found
< server: awselb/2.0

⚙️ Command Summary

PurposeCommand
Test endpointcurl -vk https://{{TEST_DOMAIN}}
DNS bypasscurl -k -H "Host: {{SERVICE_DOMAIN}}" https://{{ALB_DNS_NAME}}
Headers onlycurl -I https://{{TEST_DOMAIN}}
Follow redirectcurl -L https://{{TEST_DOMAIN}}
DNS checkdig {{TEST_DOMAIN}}
Pod logskubectl logs {{POD_NAME}}
Infra logsjournalctl -xe
Nginx reloadsudo nginx -t && sudo systemctl reload nginx