curl Name resolve curl tricks Change the "Host:" header


The "Host:" header is a normal way an HTTP client tells the HTTP server which server it speaks to. By passing custom modified "Host:" header you can have the server respond with the content of the site, even if you didn't actually connect to the host name.

For example, if you have a site on your localhost and you wish to have curl ask for its index page, the command is:

curl -H "Host:" http://localhost/

The main disadvantage of modifying the "Host:" header is that curl will only extract the SNI name to send from the given URL. In other words, the "Host:" header modification is not enough when communication with a server via HTTPS.