2013-05-22 28 views
6

मैं nginx चाहते हैं एक स्थान के सभी प्रतिक्रिया के लिए सामग्री प्रकार application/xml भेजें:Nginx डिफ़ॉल्ट सामग्री प्रकार

server { 

     server_name my_name 
     listen 8088; 
     keepalive_timeout 5; 

     location/{ 
     proxy_pass http://myhost; 

     types   { } 
     default_type application/xml 
    } 
    } 

लेकिन:

मेरे विन्यास प्रलेखन http://wiki.nginx.org/HttpCoreModule#types पर आधार है सर्वर हमेशा सामग्री-प्रकार "टेक्स्ट/एक्सएमएल" के रूप में भेजता है। कोई विचार?

+0

यदि आपके url ".xml" के साथ समाप्त होता प्रकार 'प्रकार {एक्सएमएल application/xml अंदर एक्सएमएल प्रकार के लिए' आवेदन/xml' लिए मजबूर करने की कोशिश; } ' –

+0

बेवकूफ सवाल, लेकिन क्या आप 'default_type' लाइन के बाद कॉन्फ़िगरेशन में अर्धविराम खो रहे हैं? – Slartibartfast

उत्तर

2

एक्सएमएल एक्सटेंशन के लिए डिफ़ॉल्ट प्रकार टेक्स्ट/एक्सएमएल है। यह व्यवहार 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 का उपयोग इसे ओवरराइड करने के लिए करें (एप्लिकेशन/xml पर सेट करें)। अपाचे 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

काम नहीं करता है, मुझे लगता है कि आपकी बैकएंड सर्वर कॉन्फ़िगरेशन में समस्या है। अपाचे (httpd.conf) के लिए डिफॉल्ट टाइप अक्षम करें: डिफ़ॉल्ट टाइप टाइप करें –

संबंधित मुद्दे