繁体   English   中英

更正变量名称或为Content-Disposition文件名剪切多余的字符串

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM