0

I've been reviewing some nginx configuration docs and i found this: http://nginx.org/en/docs/http/request_processing.html I'm specifically reading the section about rejecting requests that don't provide a host name.

I'm wondering how to generate these types of requests for testing purposes, and when would these types of request come in - in real life...aka do i need to care?

What I've tried so far:

I've added the following into my nginx conf file

server {
    listen      80;
    server_name "";
    return      444;
}

Then I tried to play around with curl and send a request with an empty host header like so:

curl --verbose --header 'Host:' 'http://192.1.6.1/test/hello'

That returns the error 400 bad request.

dot
  • 14,928
  • 41
  • 110
  • 218

1 Answers1

0

An old version of the Hypertext Transfer Protocol (HTTP/1.0) did not require a Host request header. See this question for details.

You can force curl to use HTTP/1.0 with the --http1.0 command line option.

Richard Smith
  • 45,711
  • 6
  • 82
  • 81