2013-05-22 6 views
6

ich NGINX möchte senden, um den Content-Type application/xml für alle Antwort eines Standortes:Nginx Standard-Content-Typ

Meine Konfiguration ist Basis für die Dokumentation 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 
    } 
    } 

Aber die Server sendet immer als Inhaltstyp "text/xml". Irgendeine Idee?

+0

wenn Ihre URL mit ".xml" endet versuchen zwingt die 'application/xml' für XML-Typ innerhalb Typen' Typen {xml application/xml; } ' –

+0

Dumme Frage, aber fehlt Ihnen ein Semikolon in der Konfiguration nach' default_type' Zeile? – Slartibartfast

Antwort

2

Der Standardtyp für die XML-Erweiterung ist text/xml. Dieses Verhalten wird in mime.types-Datei beschrieben. Verwenden Sie http://nginx.org/en/docs/http/ngx_http_core_module.html#default_type oder http://nginx.org/en/docs/http/ngx_http_core_module.html#types, um es zu überschreiben (auf application/xml gesetzt).

Lösung für Apache:

# 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

Ich habe versucht, dies als in meiner Frage zu erklären, aber es scheint nicht zu funktionieren – wonzbak

+0

Ich denke, Problem in Ihrem Backend-Server-Konfiguration. Deaktivieren Sie für Apache (httpd.conf) DefaultType: DefaultType None –