nginx - Nginx 可以解压 gzip 文件作为响应吗?
问题描述
问题:
Nginx 可以解压 gzip 文件作为响应吗?
究竟是什么?
- 请求
curl 127.0.0.1/file.json.gz
应返回解压缩的 json 作为响应。
更多细节:
- 文件存在
/path/file.json.gz
。 - Nginx 配置:
server {
location / {
gunzip on;
root /path;
}
}
- Nginx 构建包含 gunzip 模块http://nginx.org/en/docs/http/ngx_http_gunzip_module.html
nginx -V 2>&1 | grep "\-\-with\-http_gunzip_module" => ... --with-http_gunzip_module ...
- 响应是 gzip 编码的:
curl -v 127.0.0.1/file.json.gz
* Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
> GET /index.html.gz HTTP/1.1
> Host: 127.0.0.1
> User-Agent: curl/7.47.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: nginx/1.13.1
< Date: Wed, 11 Mar 2020 20:41:59 GMT
< Content-Type: application/octet-stream
< Content-Length: 392
< Last-Modified: Tue, 31 Jan 2017 15:01:11 GMT
< Connection: keep-alive
< ETag: "5890a6b7-188"
< Content-Encoding: gzip
< Accept-Ranges: bytes
<
���X�N�0
��+
解决方案
推荐阅读
- c++ - 我们什么时候需要模板元编程中的标签调度?
- amazon-web-services - 我可以为 Amazon Athena 使用 S3 终端节点吗?
- ios - 从 SwiftUI 列表导航到 UIKit 故事板?
- scala - Scala中的星和字符串组合模式
- docker - 如何修复 --tag" 标志:无效的引用格式:存储库名称在 Jenkins delcarative 管道中必须是小写的?
- javascript - 如何在 Typescript Mocha 测试挂钩中保留“this”
- r - 生成的轴刻度标签中的斜体字母
- visual-studio-2019 - 如何在 VS 2019 中禁用所有代码分析?
- python - Python 计算嵌套字典中特定键的平均值(IBM Watson Speech to Text API 结果)
- c++ - 将双精度数组重新解释为 std::complex 数组