「Nginx」- 响应设置

  CREATED BY JENKINSBOT

问题描述

该笔记将记录:在 Nginx 中,与响应有关的常见设置,以及相关问题的解决方案。

解决方案

设置响应类型

http headers – Force nginx to send specific Content-Type – Stack Overflow

default_type(Module ngx_http_core_module/default_type),设置默认 MIME 类型:

default_type application/xml;

# http, server, location

type(Module ngx_http_core_module),根据文件扩展名设置返回类型:

types {
    application/octet-stream bin exe dll;
    application/octet-stream deb;
    application/octet-stream dmg;
}

# http, server, location

注意事项,受支持的 MIME 类型参考 /etc/nginx/mime.types 文件(具体文件路径取决于发行版)。

参考文献

Module ngx_http_core_module