Return JSON for 404 error instead of html

Lord Nynex lordnynex at gmail.com
Tue May 13 06:42:03 UTC 2014


Justink101,

Using the echo module

error_page 404 @404;
location @404 { echo '{"status": "Not Found"}'; }



On Mon, May 12, 2014 at 9:08 PM, justink101 <nginx-forum at nginx.us> wrote:

> How can I return a custom JSON body on 404, instead of the default html of:
>
> <html>
>
>     <head>
>         <title>404 Not Found</title>
>     </head>
>
>     <body bgcolor="white">
>         <center>
>             <h1>404 Not Found</h1>
>         </center>
>         <hr>
>         <center>nginx</center>
>     </body>
>
> </html>
>
> Posted at Nginx Forum:
> http://forum.nginx.org/read.php?2,250033,250033#msg-250033
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20140512/1d95315e/attachment.html>


More information about the nginx mailing list