Host Header Fundamentals and Purpose
You'll learn how the HTTP Host header acts as the "address label" that routes your request to the correct application on a shared server.
What Is the Host Header?
When your browser sends an HTTP request, it includes a Host header that specifies the domain name you're trying to reach. For example:
GET /index.html HTTP/1.1
Host: www.example.com
Think of it like an apartment building: the IP address gets you to the building, but the Host header tells the server which apartment (website) you want to visit.
Why Servers Need the Host Header
Modern web servers often host multiple websites on a single IP address—a setup called virtual hosting. Without the Host header, the server wouldn't know whether you want shop.example.com, blog.example.com, or admin.example.com.
The server reads the Host header and uses it to:
- Route your request to the correct application
- Serve the right content from multiple sites
- Generate absolute URLs in responses
- Enforce security policies tied to specific domains
Security Implications
Because servers trust the Host header to determine routing, attackers can manipulate it to:
- Trick servers into routing to unintended applications
- Poison caches with malicious content
- Bypass authentication checks
- Trigger password reset emails with attacker-controlled links
The Host header is user-controlled input—yet many applications treat it as trusted infrastructure data.
Key Takeaway: The Host header is the routing mechanism that tells servers which virtual host to serve, but because it's client-controlled, it's a critical attack surface in modern web security.