Return JSON for 404 error instead of html

justink101 nginx-forum at nginx.us
Wed May 14 21:26:34 UTC 2014


Thanks for the replies and sorry about the delay in responding. This is what
we ended up using:

  error_page 404 = @four_o_four;

  location @four_o_four {
    internal;
    more_set_headers "X-Host: web4.ourdomain.com";
    more_set_headers "Content-Type: application/json";
    return 404 '{"status":"Not Found"}';
  }

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,250033,250095#msg-250095



More information about the nginx mailing list