I am trying to setup nginx to handle file uploads and pass the file information on to a backend server once done. I came across a post at https://coderwall.com/p/swgfvw that shows how to do this and I am able to see a file being uploaded to the /tmp directory. However I would like to also pass on the file name and type (Content-Disposition and Content-Type) to the backend server.
I tried capturing what is received at the http server port and see the below,
POST /upload HTTP/1.1
User-Agent: curl/7.32.0
Host: MyHostName
Accept: */*
Content-Length: 4431
Expect: 100-continue
Content-Type: multipart/form-data; boundary=------------------------6060af4f937c14c9
--------------------------6060af4f937c14c9
Content-Disposition: form-data; name="filedata"; filename="sessions.txt"
Content-Type: text/plain
followed by the data.
My nginx location block for upload is,
location /upload {
limit_except POST { deny all; }
client_body_temp_path /tmp/;
client_body_in_file_only on;
client_body_buffer_size 128K;
client_max_body_size 100M;
proxy_redirect off;
proxy_set_header X-FILE $request_body_file;
proxy_set_header X-Forwared-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Connection "";
proxy_pass_request_headers on;
proxy_set_body off;
proxy_http_version 1.1;
proxy_pass http://my_backend;
}
With this I am able to pass on and receive the following at my backend,
'content-type': 'multipart/form-data; boundary=------------------------6060af4f937c14c9'
'x-file': '/tmp/0000000001'
but would really like to know how I can get the
Content-Disposition: form-data; name="filedata"; filename="sessions.txt"
Content-Type: text/plain
to my backend. Any help with this is much appreciated.
P.S: hope its ok for this question here? (tried superuser but it doesn't seem to have much activity)