Table of Contents

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).