Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx files upload streaming with proxy_pass

I configured nginx as reverse proxy to my node.js application for file uploads with proxy_pass directive. It works, but my problem is that nginx waits for the whole file body to be uploaded before passing it to the upstream. This causes problems for me, because I want to track upload progress at my application. Any idea how to configure nginx in order to stream file body in real time to the upstream?

like image 302
bbbonthemoon Avatar asked Sep 05 '12 13:09

bbbonthemoon


People also ask

What does proxy_pass do in nginx?

The proxy_pass setting makes the Nginx reverse proxy setup work. The proxy_pass is configured in the location section of any virtual host configuration file. To set up an Nginx proxy_pass globally, edit the default file in Nginx's sites-available folder.

Does nginx support proxy protocol?

The PROXY protocol enables NGINX and NGINX Plus to receive client connection information passed through proxy servers and load balancers such as HAproxy and Amazon Elastic Load Balancer (ELB). With the PROXY protocol, NGINX can learn the originating IP address from HTTP, SSL, HTTP/2, SPDY, WebSocket, and TCP.

Does nginx support FTP?

But by default nginx doesn't support FTP as proxy protocol.


2 Answers

There is no way to (at least as of now). Full request will be always buffered before nginx will start sending it to an upstream. To track uploaded files you may try upload progress module.

Update: in nginx 1.7.11 the proxy_request_buffering directive is available, which allows to disable buffering of a request body. It should be used with care though, see docs.

like image 135
Maxim Dounin Avatar answered Oct 09 '22 23:10

Maxim Dounin


Tengine (a fork from nginx) support unbuffered upload by setting proxy_request_buffering to off.

http://tengine.taobao.org/document/http_core.html

Updated: in nginx 1.7.11 the proxy_request_buffering directive is available, as @Maxim Dounin mentioned above

like image 20
Tolbkni Kao Avatar answered Oct 09 '22 22:10

Tolbkni Kao