[英]Correct variable name or cut extra-string for Content-Disposition filename
我将此位置用作端口3000处Web服务的终结点,它返回CSV以供下载。
此(以下)配置提供了一个好的文件名,但没有扩展名,因此需要将“ .csv”连接到它。 默认文件名(来自localhost:3000还是来自request_filename?)很好,但是我不知道NGINX变量$something_default
。
location /_test/ {
proxy_set_header Host $host;
proxy_set_header Accept 'text/csv';
proxy_pass http://localhost:3000/;
}
其他配置提供的文件名错误但扩展名良好 。 我需要剪切翻译成“ _”字符串的多余路径。
location /_test/ {
proxy_set_header Host $host;
add_header Content-Disposition 'attachment; filename="$request_filename.csv"';
proxy_set_header Accept 'text/csv';
proxy_pass http://localhost:3000/;
}
因此,标头正在工作,是解决方案的一部分,但需要一个正确的变量(注释$something_default
)。
由Github的@ steve-chavez回答。
http {
upstream myproject {
server localhost:3000;
}
server {
location /_test/ {
proxy_pass http://myproject/;
location ~ ^/_test/(.*)\.csv$ {
proxy_set_header Accept 'text/csv';
proxy_pass http://postgrest/$1$is_args$args;
}
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.