.json requests return 404

Hello all,

I'm moving from hosted to open source and have 2.4b1 installed on Nginx + Php7-fpm.

Everything is working fine except that requests to .json such as /settings/analyticstick.json etc are returning 404 errors. I think this must be a config issue with Nginx and PHP.

Here is the site conf:

server {
listen 80;
server_name vdev.mysite.com;
root /home/vanilla/public_html;
index index.php index.html;

location / {
    try_files $uri $uri/ =404;
    rewrite ^/(.+)$ /index.php?p=$1 last;
}

location ~ \.(eot|woff|ttf|svg|js|jpg|png|css)(.*)$ {
    root /home/vanilla/public_html/;
}

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}

location ~ /\.ht {
    deny all;
}

}

fastcgi-php.conf

regex to split $uri to $fastcgi_script_name and $fastcgi_path

fastcgi_split_path_info ^(.+.php)(/.+)$;

Check that the PHP script exists before passing it

try_files $fastcgi_script_name =404;

Bypass the fact that try_files resets $fastcgi_path_info

see: http://trac.nginx.org/nginx/ticket/321

set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;

fastcgi_index index.php;
include fastcgi.conf;

the fastcgi.conf is empty

I'm new at Nginx so I'm not sure what's missing here that is causing Nginx to return 404s for the .json requests.

Comments

  • Something really screwed up the fastcgi-php.conf output there. :/

  • I fixed this by using one of the nginx configs found here in the forums. Thanks!

  • @HIAviator

    If you provide a link to the solution you found, it may help others in the future.

Sign In or Register to comment.