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

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm experiencing strange behaviour with Nginx. In my case Nginx acts as proxy to Jetty. Config below:

server {
    listen   80;
    client_header_timeout 3m;
    client_body_timeout 3m;
    send_timeout 3m;
    client_max_body_size 5M;
    location / {
         auth_basic     "Restricted area";
         auth_basic_user_file   /etc/nginx/htpasswd;
         proxy_pass        http://localhost:8080;
         proxy_set_header  X-Real-IP $remote_addr;
         proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
         proxy_set_header  X-Forwarded-Proto http;
         proxy_set_header  X-Real-IP $remote_addr;
         proxy_set_header  Host $http_host;
         gzip on;

When uploading a file with size greater than 5M I'm getting a'Gateway timeout'. CPU usage is 0%. I've no idea what's wrong. It's not related to a network speed because I'm testing this locally.

If I skip a proxy and try to upload file to app server directly (i mean: on port 8080), everything works like a charm.

Any idea ?? Regards!

share|improve this question
Application handles a files larger than 5M. The main issue is with GW timeouts. A request with files bigger than 5M never comes to application server. – tomekkup Aug 7 '12 at 9:17

Probably you need to change the limit at

 client_max_body_size 5M;

to something like

 client_max_body_size 10M;
share|improve this answer
OK. but app server can handle files larger than 1GB and return exception bla bla bla. – tomekkup Aug 7 '12 at 9:18

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.