Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

configuring nginx to serve static json files

Switching to nginx for a site, one issue I'm having is serving up static json files.

I added to the mime types:

application/zip                         zip;
...
application/json                        json;
...

and restarted but it tried serving it up as a download (ie http://domain.com/json-tmp/locations.json). What else would I need to configure?

thx

like image 369
timpone Avatar asked Dec 29 '11 17:12

timpone


2 Answers

I had to add

    application/json                      json;

in /etc/nginx/mime.types and restart nginx to make it work.

like image 177
Andre Baumeier Avatar answered Nov 09 '22 23:11

Andre Baumeier


I know this post is quite old but adding application/json mime type to nginx configuration file plus restarting the server should work.

When you request the json file try to debug the response header and check if the Content-Type header was successfully changed to application/json.

like image 24
leonfs Avatar answered Nov 09 '22 23:11

leonfs