Configuring nginx to serve static json files

Switching to nginx for the site, one problem that I encountered is serving static json files.

I added mime types:

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

and rebooted, but he tried serving it as a download (i.e. http://domain.com/json-tmp/locations.json ). What else do I need to configure?

THX

+8
ruby-on-rails nginx
source share
3 answers

I know this post is pretty old, but adding the / json mime type to the nginx configuration file and restarting the server should work.

When you request a json file, try debugging the response header and check if the Content-Type header has been successfully changed to application / json.

+2
source share

I had to add

  application/json json; 

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

+4
source share

Try using it as javascript ...

 application/javascript json; 

Or like plain text ...

 text/plain txt json; 

I'll try javascript first.

0
source share

All Articles