Return JSON for 404 error instead of html

justink101 nginx-forum at
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 {
    more_set_headers "X-Host:";
    more_set_headers "Content-Type: application/json";
    return 404 '{"status":"Not Found"}';

Posted at Nginx Forum:,250033,250095#msg-250095

More information about the nginx mailing list