ALB Request and Response Modifications
What you'll learn: How Application Load Balancers can modify HTTP headers, redirect requests, and return custom responses without forwarding traffic to backend servers.
The Power to Adjust Traffic In-Flight
Think of an Application Load Balancer as a smart postal worker who doesn't just forward letters—they can also add stamps, change addresses, or even write simple replies without bothering the main office. ALB can modify HTTP requests and responses as they pass through, giving you powerful traffic control right at the edge.
Three Key Modification Capabilities
1. Insert or Modify HTTP Headers
ALBs can add new headers or change existing ones before forwarding requests to your targets. Common use cases include:
- Adding
X-Forwarded-Forheaders to preserve original client IP addresses - Injecting custom headers with routing metadata
- Setting
X-Amzn-Trace-Idfor distributed tracing
2. Redirect Requests
You can configure ALB listener rules to redirect traffic to different URLs. Perfect for:
- HTTP-to-HTTPS redirects (forcing secure connections)
- Moving users from old URLs to new ones
- Redirecting based on host headers or paths
3. Return Fixed Responses
ALB can return a custom response directly without contacting backend targets:
- Maintenance page messages
- Simple error codes (like
503 Service Unavailable) - Static responses for health checks or blocked requests
Why This Matters
These features reduce backend workload, improve security (by handling redirects at the edge), and simplify application code—your servers don't need to handle basic redirects or header manipulation.
Key Takeaway: ALBs can insert/modify headers, redirect requests, and return custom fixed responses directly, giving you powerful traffic manipulation without touching your backend application code.