Nginx默认内容类型

前端之家收集整理的这篇文章主要介绍了Nginx默认内容类型前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我想Nginx发送内容类型的application / xml
对于某个位置的所有响应:

我的配置基于文档http://wiki.nginx.org/HttpCoreModule#types

 server {

      server_name my_name
      listen 8088;
      keepalive_timeout 5;

      location / { 
        proxy_pass http://myhost;

        types         { } 
        default_type  application/xml
     }   
   }
@H_502_10@

但是服务器总是以内容类型“text / xml”发送.
任何的想法?

最佳答案
xml扩展名的默认类型是text / xml. mime.types文件中描述了此行为.使用http://nginx.org/en/docs/http/ngx_http_core_module.html#default_typehttp://nginx.org/en/docs/http/ngx_http_core_module.html#types覆盖它(设置为application / xml).

apache解决方案httpd:

# DefaultType: the default MIME type the server will use for a document
# if it cannot otherwise determine one,such as from filename extensions.
# If your server contains mostly text or HTML documents,"text/plain" is
# a good value.  If most of your content is binary,such as applications
# or images,you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.

DefaultType None
@H_502_10@

http://httpd.apache.org/docs/current/mod/core.html#defaulttype

原文链接:https://www.f2er.com/nginx/434811.html

猜你在找的Nginx相关文章