I'm using nginx-1.7.0 on windows 7. I am trying to use add_header to get to a json file I have residing in /data/TESTFOLDER.
This is what my location block looks like:
location /data/TESTFOLDER/ {
add_header 'Content-Type' 'application/json';
autoindex on;
}
When I run my website, where in my javascript I have a jquery ajax request to get json files from this folder, firebug gives me this information:
ResponseHeaders
Connection keep-alive
Content-Type text/html
Date Wed, 09 Jul 2014 14:01:29 GMT
Server nginx/1.7.0
Transfer-Encoding chunked
Request Headers
Accept application/json
Accept-Encoding gzip, deflate
Accept-Language en-us,is;q=0.7,en;q=0.3
Content-Type application/json
Host localhost
Referer http:// local host/index.html
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:30.0) Gecko/20100101 Firefox/30.0
X-Requested-With XMLHttpRequest
so you see the content-type hasn't changed as I would like it to. I have no add_header's elsewhere in my config file and the default is set to octet_stream like it should be.
A couple of things to note:
- The request "works", that is, I can access local host/data/TESTFOLDER/ from my browser
- mime.types are included in my config file
- mime.types contains application/json json;
- my error log has no errors about this
Also, I'm very new to nginx and web servers in general, so please make your explanations simple to understand. :)
application/json
as the Content-Type in those headers...isn't that what you want?text/html
.