Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NGINX Reverse Proxy : Many html status code 400 responses, why?

We have recently implemented a nginx based reverse proxy.

While, debugging our access logs, we are seeing quite a bit of status code 400 results.

They look something like this:

[07/Sep/2011:05:49:04 -0700] - "400" 0 "-" "-" "-"

We have enabled debug error logging, and they usually correspond to something like this:

2011/09/07 05:09:28 [info] 5937#0: *30904 client closed prematurely connection while reading client request line

We have tried raising a number of the buffers, as mentioned by a few pages we were able to google up.

http://www.ruby-forum.com/topic/173362

or

http://blog.craz8.com/articles/2009/06/17/nginx-400-bad-request-errors-due-to-cookies-and-what-to-do-about-them

To no avail.

Why is this happening?

This is a strandard nginx reverse proxy -> apache backend server.

Worth mentioning, the unique type of content on our site is fairly minimal. We have tested this using many browsers and are not personally receiving any of these 400 results.

Thanks!


Further urls detailing similar entries in their logs:

http://blog.rayfoo.info/2009/10/weird-web-server-access-log-entries

like image 940
anonymous-one Avatar asked Sep 07 '11 12:09

anonymous-one


People also ask

Why does Nginx return 400?

Occasionally, you may run into a recurring issue with some of your websites: Nginx returns 400 Bad Request error pages to random visitors, and this only stops happening when visitors clear their cache and cookies. The error is caused by an overly large header field sent by the client.

Why use Nginx reverse proxy?

The benefits of using Nginx as a reverse proxy include: Clients access all backend resources through a single web address. The reverse proxy can serve static content, which reduces the load on application servers such as Express, Tomcat or WebSphere.

What is Proxy_set_header Nginx?

To adjust or set headers for proxied connections, use the proxy_set_header directive, followed by the header value. You can find a list of all available Request Headers and their allowed values here . If you want to prevent a header from being passed to the proxied server, set it to an empty string "" .


2 Answers

I found this was caused by using Chrome, which apparently opens extra connections occasionally without sending any data.

Here's some more info: http://www.ruby-forum.com/topic/2953545

Now the question is what to do about them - the answer provided there wasn't very satisfying.

like image 164
Ross117 Avatar answered Sep 20 '22 15:09

Ross117


Are you handling SSL connections? Can you add $ssl_cipher $ssl_protocol to your access log format?

like image 44
Jehiah Avatar answered Sep 21 '22 15:09

Jehiah