Nginx pass file type to backend server

I am trying to configure nginx to handle file downloads and transfer file information to the server server after it is completed. I came across a message in https://coderwall.com/p/swgfvw which shows how to do this and I can see how the file is uploaded to the / tmp directory. However, I would also like to pass the file name and type (Content-Disposition and Content-Type) to the server server.

I tried to capture what was received on the http server port and see 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 data.

My nginx location block to load 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 can send and receive the following on my server,

 'content-type': 'multipart/form-data; boundary=------------------------6060af4f937c14c9' 'x-file': '/tmp/0000000001' 

but I would love to know how I can get

 Content-Disposition: form-data; name="filedata"; filename="sessions.txt" Content-Type: text/plain 

for my backend. Any help with this is much appreciated.

PS: Hope this is normal for this question? (tried superuser, but he doesn't seem to have much activity)

+6
source share
2 answers

if the title is ignored try

 proxy_pass_header Content-Disposition; 

or directly transfer

 proxy_set_header Content-Disposition $http_content_disposition; 
0
source

Underscores in custom headers are silently ignored in nginx, an option that may help

underscores_in_headers on;

0
source

All Articles