What is the HTTP Host Header and how it is used?

About

host 1) in the context of HTTP is a header field that:

  • indicates the destination of the request
  • and is part of the origin definition

The Host field value is the network location of the origin server or gateway given by the original URL.

The value is:

Example

Example of a get request to the URL http://www.w3.org/pub/WWW/

GET /pub/WWW/ HTTP/1.1
Host: www.w3.org

Usage

It's used:

  • to route the request to its destination server on the network.
  • to host several domain on the same host (virtual domain)

Virtual Domain

One server (one host) can serve multiple domain thanks to the host header. The web server looks the value up and therefore can change the destination of the request. See What is and how works a virtual host / custom domain / vanity hostnames

Network Route

This value is used (generally with TCP/IP) to route the message to the destination server.

Gateway / Proxy

It's also used to route the request to the destination website (A server may host several hostname called virtual host)

The http Server uses this value to create optionally virtual host.

On a Apache server for instance, the host value is mapped to the ServerName property of the configuration file in order to route the request to the backend web site.

Set

The host is a header that is set by the client in a request.

In a get request, the client (generally the browser) sets it by default from the value found in the URL.

Support

Invalid Host header: Error

If you get this error, it means that the host header value does not match the listening host configuration of your web server.

You can solve it by:

  • renaming the host header value to the correct value
  • modifying the listening hostname of your web server to 0.0.0.0 (It means that your web server accepts all hosts name).





Discover More
Cookie Scope Name
Cookie - Scope

The scope of a cookie name is a calculated property defined by the concatenation of the and attributes. If the request URL matches the scope (ie domain and path expression), the user agent (browser)...
Origin Http Header
HTTP - Origin Server (Header Field)

The Origin header is: a header field added to a request by the browser (ie client) with the origin value that indicate the source of the code (HTML, Javascript, ...) that created the request....
HTTP - Port (80, 443)

The HTTP request are routed to the destination server defined by the host and port of the request URL authority. If the port is not defined, the default ports are: 80 for the http scheme 443 for...
Chrome Devtool Har
HTTP - Request

An HTTP request is a message sent from a client to a server. It's the first part of a fetch, the second being the response. A request message has: a first line called the request...
HTTP Connection management

An HTTP fetch creates a network connection. This article gives you an overview and direct your to the reference documentation for more information
Map Of Internet 1973
Network - Endpoint (Network Location, host)

An endpoint is the final address of a service defined by: a host and a port number. In the web, the endpoint is commonly referred as the host but in the network community, a host is just a server....
Nginx - HTTP Request Processing

How nginx process a HTTP request nginx first decides which server should process the request with: The request’s header field “Host”. If its value does not match any server name, or the request...
Server Name Indication (SNI)

Server_Name_Indication is an extension to the TLS computer networking protocol (not SSL) by which a client indicates which hostname it is attempting to connect to at the start of the handshaking process....
Set Cookie Block Bad Domain Att Vs Current Host Url
The domain property of a cookie in depth

This article is about the domain property of a cookie and defines what is a domain, how it's used and what's permitted.
What is Hosting? (or hosted domains for HTTP, Email, )

Hosting is when the domains of a request are not directly associated with the machine's name. The domains are then called hosted. web hosting is when a web/http server is provided to you. You...



Share this page:
Follow us:
Task Runner