I would like Nginx to 444
when processing a request without a host
header.
I have read http://nginx.org/en/docs/http/request_processing.html and Nginx default host when not defined, where it says:
"If its value does not match any server name, or the request does not contain
this header field at all, then nginx will route the request to the default server
for this port."
I've configured
server {
listen 80 default_server;
# Since version 0.8.48, this is the default setting for the server name,
# so the server_name "" can be omitted.
# server_name "";
return 444;
}
Then I request
telnet localhost 80<enter>
GET / HTTP/1.1<enter>
<enter>
and receive a 400
, not the 444
I expected:
HTTP/1.1 400 Bad Request
Server: nginx/1.2.5
Date: Wed, 28 Nov 2012 21:01:59 GMT
Content-Type: text/html
Content-Length: 172
Connection: close
[body]
The same happens when I
telnet localhost 80<enter>
GET / HTTP/1.1<enter>
Host:<enter>
How can I get Nginx to 444 when no host
header is provided? Is this not possible if the the server considers the request a bad request?