Can't upload big files via nginx as reverse proxy
Maxim Dounin
mdounin at mdounin.ru
Tue Jun 5 07:54:17 UTC 2012
Hello!
On Tue, Jun 05, 2012 at 03:33:24AM -0400, speedfirst wrote:
> Hey.
>
> In my env, the layout is:
>
> client <--> nginx <--> jetty
>
> In the client, there is a <input type=file> control. I tried to upload a
> file with size of 3.7MB. In the client request, the content type is
> "multipart/form-data", and there is an "Expect: 100-continue" header.
>
> Through tcpdump, I could see nginx immediately return an "HTTP/1.1 100
> Continue" response, and started to read data. After buffering the
> uploaded data, nginx then started to send them to jetty. However in this
> time, no "Expect: 100-continue" header was proxied because HTTP/1.0 is
> used.
So far this is expected behaviour.
> After sending part of data, nginx stopped continuing to proxy the rest
> of data, but the connection is kept. After 30s, jetty reports time out
> exception and returned an response. Nginx finally proxied this response
> back to client.
>
> I simply merged all the tcp segments which was sent from nginx to jetty,
> and found only 400K bytes are proxied.
This is obviously not expected.
Anything in error log? Could you please provide tcpdump and debug
log? It would be also cool to see which version of nginx you are
using, i.e. please provide "nginx -V" output, and a full config.
>
>
> My nginx config is quite simple, just
>
> server {
> listen 80;
> location / {
> proxy_pass http://upstream;
> }
> }
This misses at least "client_max_body_size" as by default 3.5MB
upload will be just rejected.
>
> All proxy buffer config was not explicitly set so the default values
> were applied. I tried to "proxy_buffering off;" and re-do the experiment
> above and find the result was same.
Proxy buffers, as well as proxy_buffering, doesn't matter, as it
only affects sending response from an upstream to a client.
> I also tried to observe the temp file written by nginx but it's
> automatically removed when everything is done. Any way to keep it?
client_body_in_file_only on;
See here for details:
http://nginx.org/r/client_body_in_file_only
Maxim Dounin
More information about the nginx
mailing list