Nginx中CSV文件的重复内容类型标题
我有一些直接从文件系统通过Nginx提供的Nginx中CSV文件的重复内容类型标题,nginx,Nginx,我有一些直接从文件系统通过Nginx提供的.csv文件。 当前看起来是这样的:: location ~ /static/csv_exports/ { add_header Content-Type text/csv; } 出于某种原因,我不得不这样做,因为否则它将被用作text/plain。下面是我在上面做卷曲时得到的结果: $ curl -v http://localhost/static/csv_exports/20110322_172651.csv >> /d
.csv
文件。
当前看起来是这样的::
location ~ /static/csv_exports/ {
add_header Content-Type text/csv;
}
出于某种原因,我不得不这样做,因为否则它将被用作text/plain
。下面是我在上面做卷曲时得到的结果:
$ curl -v http://localhost/static/csv_exports/20110322_172651.csv >> /dev/null
...
< HTTP/1.1 200 OK
< Server: nginx/0.7.67
< Date: Tue, 22 Mar 2011 17:32:07 GMT
< Content-Type: text/plain
< Content-Length: 356623
< Last-Modified: Tue, 22 Mar 2011 17:26:52 GMT
< Connection: keep-alive
< Cache-Control: public
< Content-Type: text/csv
< Accept-Ranges: bytes
$curl-vhttp://localhost/static/csv_exports/20110322_172651.csv >>/dev/null
...
瞧!它有两个“内容类型”标题。在浏览器中打开它会自动打开Open Office,它工作正常,但我怀疑我做得不对 太棒了!我不知道
类型
指令的事情。对我来说也很有用,当让nginx返回自定义字符串时,它添加了文本/普通内容类型。
location ~ /static/csv_exports/ {
- add_header Content-Type text/csv;
+ types {text/csv csv;}
}