2013-05-22 11 views
6

私はnginxの場所のすべての応答のコンテンツ・タイプapplication/xmlの を送りたいと思います:nginxのデフォルトのコンテンツタイプ

私の構成では、ドキュメント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 
    } 
    } 

しかし、サーバーは常にcontent-type "text/xml"として送信します。

+0

あなたのURLが ".xmlの" で終わる場合タイプ 'タイプ{XMLアプリケーション/ XML内のXML型のため、'アプリケーション/ xml'を強制してみてください。 } ' –

+0

愚かな質問ですが、' default_type'行の後にセミコロンを設定していませんか? – Slartibartfast

答えて

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

+0

私は私の質問でこれを説明してみましたが、うまくいきません。 – wonzbak

+0

あなたのバックエンドサーバーの設定で問題があると思います。 Apache(httpd.conf)の場合は無効にするDefaultType:DefaultType None –

関連する問題