HTTP status codes missing description in header for proxy_pass

We’re using nginx as a middle layer in front of our application server
(mod_perl). When mod_perl returns an error page, the HTTP status line
missing the “reason phrase” after the status code, like “Not Found”,

HTTP/1.1 404
Server: nginx/1.2.1

should be

HTTP/1.1 404 Not Found

AFAICT, the HTTP spec requires at least a space after the status code:
The first line of a Full-Response message is the Status-Line,
consisting of the protocol version followed by a numeric status code
and its associated textual phrase, with each element separated by SP
characters. No CR or LF is allowed except in the final CRLF sequence.

   Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF

Since a status line always begins with the protocol version and
status code


(e.g., "HTTP/1.0 200 "),

   Reason-Phrase  = *<TEXT, excluding CR, LF>

The reason we noticed is that putting Perlbal in front of nginx got the
status rejected, since Perlbal is written to strictly follow the spec:

return fail(“Bogus response line”) unless
$self->{responseLine} =~


nginx does its job correctly:

$ curl -I
$ HTTP/1.1 404 Not Found
$ […]

I guess the irregular response comes from your mod_perl backend? Did you
check that out?

Capturing nginx’s debug output of such a request will probably help.



On Mon, Jun 03, 2013 at 07:07:50PM -0400, kgoess wrote:

HTTP/1.1 404 Not Found


Is this a bug in nginx, or a configuration issue that we can fix? The patch
to Perlbal is simple enough, is it worth looking for a patch to nginx? Or
did we miss something else entirely?

As soon as you proxy requests to another server - nginx just
returns a status line as got from a backend as soon as it’s able
to recognize it.

Maxim D.

I guess the irregular response comes from your mod_perl backend?

Aha, from ngrep listening on port 8080 responding to nginx, it is indeed
missing the description:

T → [AP]
HTTP/1.1 404…Server: Apache/2.2.16 (Debian) mod_perl/2.0.4

If apache is in the middle layer, instead of nginx, it looks like apache
fills in the status line

T → [AP]
HTTP/1.1 404 Not Found…Date: Tue, 04 Jun 2013 20:02:03 GMT…Server:
Apache/2.2.16 (Debian) mod_perl/2.0.4 Perl/v5.10.1…

but if nginx is in the middle, it just passes it straight through:

T → [AP]
HTTP/1.1 404…Server: nginx/1.2.1…

And sure enough, some pretty old cgi code needed this fix

 if (! -e $file) {
  •  $self->out( $cgiutils->header( -status => 404 ) );
  •  $self->out( $cgiutils->header( -status => '404 Not Found' ) );
     $self->out( $cgiutils->start_html(

Thanks for the help!

Posted at Nginx Forum: