Weird HTTP Error 400 with NginX

Just came across this rather interesting issue.

I use Munki Enroll to automatically create individual manifests for my clients.

My webserver is Nginx 1.9 on Debian Wheezy

At one site I was seeing a HTTP 400 Error coming back from my webserver when I was trying to create a manifest for the client.

HTTP/1.1" 400 172 "-" "-"

The name of the school was in the format: ‘My School HS’ the HS for me indicates High School. But it was being sent to nginx unencoded in the url.

For example, I was sending

curl --max-time 5 --get -d school_name="My School HS"

And nginx was receiving:

"GET /munki-enroll/enroll.php?school_name=My School HS HTTP/1.1" 400 172 "-" "-"

As it turns out, there is a bug? in nginx that when it passed an unencoded url that contains a space followed by a capital H it throws a 400 error.

Here is the bug report… from 3 years ago!

Looks like it is related to how Nginx delimts between the URL and the protocol “HTTP/1.1”

So the easy fix was simply to take my school name and replace the spaces with underscores.

Something like this in my script:

school_name="My School HS"
school_name_nospaces=`echo $school_name | tr ' ' '_'`

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s