我希望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
}
}
但是服务器总是以内容类型“text / xml”发送。 有什么想法吗?
答案 0 :(得分:2)
xml扩展名的默认类型是text / xml。 mime.types文件中描述了此行为。使用http://nginx.org/en/docs/http/ngx_http_core_module.html#default_type或http://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
http://httpd.apache.org/docs/current/mod/core.html#defaulttype