Reputation: 125
I have a reverse proxy server that takes file from fileserver than sends them to user. I want to change filename before sending. I wrote a rule like below
location ~ downloads/(.*) {
proxy_pass http://HOST:PORT/remote.php/dav/files/$1;
add_header Content-Disposition 'attachment; "filename=$args"';
}
But when i send request i get this error;
ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION
Upvotes: 4
Views: 9165
Reputation: 44316
Adding a header with add_header
works well with proxy pass, but if there is an existing header value in the response it will stack the values.
If you want to replace a header value (for example replace this Content-Disposition
then you will have to do this in two steps:
# 1. hide the Content-Disposition from the server response
proxy_hide_header Content-Disposition;
# 2. add a new Content-Disposition header with your changes
add_header Content-Disposition 'attachment; "filename=$args"';
See my answer on a similar question here.
Upvotes: 9