Hi, I have moved from apache to NGINX+PHP-FPM, now there some problem with .json file, In apache whenver I access .json file the output shows on browser page. But in NGINX its try to download. Would you please help me who to solve this issue? Best Regards, Umar Posted at Nginx Forum: http://forum.nginx.org/read.php?2,227766,227766#msg-227766
on 2012-06-21 15:51
on 2012-06-21 16:00
You have to add .json to your mime.types file (the default for unknown file extensions is default_type application/octet-stream; which usually all browsers download). Egg open conf/mime.types find the line: text/plain txt; add json there: text/plain txt json; .. and reload or restart nginx (clear browser cache to be sure). rr
on 2012-06-21 16:01
On Thursday 21 June 2012 17:51:10 umar wrote: > Hi, > > I have moved from apache to NGINX+PHP-FPM, now there some problem with > .json file, In apache whenver I access .json file the output shows on > browser page. But in NGINX its try to download. > > Would you please help me who to solve this issue? http://nginx.org/r/types You should set "application/json" for .json files. wbr, Valentin V. Bartenev
on 2012-06-21 16:18
Hi guys, thanks alot its fixed, Best Regards, Umar Posted at Nginx Forum: http://forum.nginx.org/read.php?2,227766,227771#msg-227771
on 2012-11-20 03:54
I am having that exact same problem. I've update mime.types config file added application/json json; and restart Nginx a zillion times but still nothing changed! is there any extra step I should do? does that change take time, because of Nginx caching? thanks Posted at Nginx Forum: http://forum.nginx.org/read.php?2,227766,232991#msg-232991
on 2012-11-20 04:30
@bach it could be a content-disposition header (attachment) being added. Can you paste your nginx.conf/vhost file? Regards, Justin Dorfman <http://www.twitter.com/jdorfman> NetDNA <http://www.netdna.com> The Science of Acceleration
on 2012-11-20 04:49
Thanks Justin,
here's how my config looks like. Please note the 2 Pyramid apps at the
bottom, from which I am trying to server the json file.
Anything obviously wrong with that setup that could be affecting the
header?
thanks
========================
user www www;
worker_processes 1;
#error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;
#pid /var/db/nginx/nginx.pid;
events {
# After increasing this value You probably should increase limit
# of file descriptors (for example in start_precmd in startup
script)
worker_connections 1024;
}
http {
include /opt/local/etc/nginx/mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local]
"$request"
'
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root share/examples/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root share/examples/nginx/html;
}
}
#first pyramid App - App1
server {
listen 80;
server_name app1.com www.app1.com;
access_log /home/app1.com/web/env/access.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 60s;
proxy_send_timeout 90s;
proxy_read_timeout 90s;
proxy_buffering off;
proxy_temp_file_write_size 64k;
proxy_pass http://127.0.0.1:5000;
proxy_redirect off;
}
}
# my second pyramid App - App2
server {
listen 80;
server_name app2.com www.app2.com;
access_log /home/app2.com/logs/access.log;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 60s;
proxy_send_timeout 90s;
proxy_read_timeout 90s;
proxy_buffering off;
proxy_temp_file_write_size 64k;
proxy_pass http://127.0.0.1:5003;
proxy_redirect off;
}
}
}
</pre>
Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,227766,232994#msg-232994
on 2012-11-20 05:09
@bach who is the owner & what permissions are on this file?: /opt/local/etc/nginx/mime.types; please run: ls -alh /opt/local/etc/nginx/mime.types Also can you post your mime.types on pastebin or gist? Regards, Justin Dorfman <http://www.twitter.com/jdorfman> NetDNA <http://www.netdna.com> The Science of Acceleration Email / gtalk: jdorfman@netdna.com M: 818.485.1458 Skype: netdna-justind Twitter: @jdorfman <http://www.twitter.com/jdorfman> www.NetDNA.com <http://www.netdna.com/> | www.MaxCDN.com<http://www.maxcdn.com/> @NetDNA <http://twitter.com/NetDNA> | @MaxCDN <http://twitter.com/MaxCDN>
on 2012-11-20 05:16
sure this is the mime.types file https://gist.github.com/4115943 and persmissions # ls -alh /opt/local/etc/nginx/mime.types -rw-r--r-- 1 root root 3.2K Nov 20 02:43 /opt/local/etc/nginx/mime.types thanks mate for your help Posted at Nginx Forum: http://forum.nginx.org/read.php?2,227766,232996#msg-232996
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.