I have Nginx setup to reverse proxy all files ending in .php. In some scripts, I check for parameters and send "406 Not Acceptable" as a generic error which needs to be picked up on jQuery/from Ajax. I can change the error but I'd like to be able to send it to the client side. If I send 406, Nginx changes it into 502 Bad Gateway and injects it's own error message.
It works for 404 and 403 though, but those errors aren't really "applicable" in this circumstance; it's an API so forbidden isn't good RESTful practice.
I tried using fastcgi_intercept_errors but that seems to not make a difference.
I'm using Nginx 0.7.
Part of the PHP:
header($_SERVER['SERVER_PROTOCOL'] . '406 Not Acceptable');
echo '{"error":"Missing Params"}';
exit;
Nginx Config
location ~ .php$ {
fastcgi_intercept_errors on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}