5

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;
    server_name test.com www.test.com
    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!

tomekkup
  • 151
  • 1
  • 1
  • 3
  • 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 07 '12 at 09:17

2 Answers2

8

Probably nginx upstream timeout needs to be increased. Try adding below to your upstream conf.

proxy_connect_timeout       600;
proxy_send_timeout          600;
proxy_read_timeout          600;
send_timeout                600;
1

Probably you need to change the limit at

 client_max_body_size 5M;

to something like

 client_max_body_size 10M;
Farhan
  • 4,269
  • 11
  • 49
  • 80