Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I would like Nginx to 444 when processing a request without a host header.

I have read 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>

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


The same happens when I

telnet localhost 80<enter>
GET / HTTP/1.1<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?

share|improve this question

1 Answer 1

HTTP 1.1 requests must contain a host header. If they don't do so, a server must reply with error 400. See also RFC 2316, section 14.23

share|improve this answer
Good! Thank you Dennis. – dimadima Nov 28 '12 at 21:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.