Re: Return JSON for 404 error instead of html

2014-05-15 Thread Francis Daly
On Wed, May 14, 2014 at 06:38:45PM -0400, justink101 wrote: Hi there, > If I try and > fetch a header that I know is being returned from the proxy it is > undefined. > > location @four_o_four { > internal; > more_set_headers "X-Host: $sent_http_x_host"; What value do you think $sent_htt

Re: Return JSON for 404 error instead of html

2014-05-14 Thread justink101
Noticed that the proxy request response headers are being thrown away in our 404 block. Note that the proxied request is returning 404. If I try and fetch a header that I know is being returned from the proxy it is undefined. location @four_o_four { internal; more_set_headers "X-Host: $sen

Re: Return JSON for 404 error instead of html

2014-05-14 Thread justink101
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 '{"stat

Re: Return JSON for 404 error instead of html

2014-05-13 Thread B.R.
Many thanks to both of you! Another step in deeper understanding on how to use nginx. :o) --- *B. R.* On Tue, May 13, 2014 at 10:13 PM, Francis Daly wrote: > On Tue, May 13, 2014 at 09:15:16PM +0200, B.R. wrote: > > I understand the logic, but when using that handler through error_page > 404 >

Re: Return JSON for 404 error instead of html

2014-05-13 Thread Francis Daly
On Tue, May 13, 2014 at 09:15:16PM +0200, B.R. wrote: > I understand the logic, but when using that handler through error_page 404 > @404, won't the handler's 200 status overload the original 404 one? http://nginx.org/r/error_page indicates that it won't unless "=" is used. f -- Francis

Re: Return JSON for 404 error instead of html

2014-05-13 Thread B.R.
I understand the logic, but when using that handler through error_page 404 @404, won't the handler's 200 status overload the original 404 one? --- *B. R.* On Tue, May 13, 2014 at 4:37 PM, Valentin V. Bartenev wrote: > On Tuesday 13 May 2014 15:30:56 B.R. wrote: > > > Instead of using 3rd-party

Re: Return JSON for 404 error instead of html

2014-05-13 Thread Justin Dorfman
application/octet-stream it is =p Regards, Justin Dorfman Director of Developer Relations MaxCDN Email / IM: jdorf...@maxcdn.com Mobile: 818.485.1458 Twitter: @jdorfman On Tue, May 13, 20

Re: Return JSON for 404 error instead of html

2014-05-13 Thread Valentin V. Bartenev
On Tuesday 13 May 2014 08:48:50 Justin Dorfman wrote: > Out of curiosity, would the mime/content type show up as application/json > or text/plain? > It depends on the default_type directive: http://nginx.org/r/default_type wbr, Valentin V. Bartenev

Re: Return JSON for 404 error instead of html

2014-05-13 Thread Justin Dorfman
Out of curiosity, would the mime/content type show up as application/json or text/plain? Regards, Justin Dorfman Director of Developer Relations MaxCDN Email / IM: jdorf...@maxcdn.com Mobile: 818.485.1458 Twitter: @jdorfman

Re: Return JSON for 404 error instead of html

2014-05-13 Thread Valentin V. Bartenev
On Tuesday 13 May 2014 15:30:56 B.R. wrote: > > Instead of using 3rd-party echo module, you can utilize the return > > directive > > > > for the same purpose: > > return 200 '{"status": "Not Found"}'; > > > > Reference: http://nginx.org/r/return > > > > wbr, Valentin V. Bartenev > > ​I woul

Re: Return JSON for 404 error instead of html

2014-05-13 Thread B.R.
> > Instead of using 3rd-party echo module, you can utilize the return > directive > for the same purpose: > > return 200 '{"status": "Not Found"}'; > > Reference: http://nginx.org/r/return > > wbr, Valentin V. Bartenev > ​I would have intuitively written code 404 rather than 200 on this one s

Re: Return JSON for 404 error instead of html

2014-05-13 Thread Valentin V. Bartenev
On Monday 12 May 2014 23:42:03 Lord Nynex wrote: > Justink101, > > Using the echo module > > error_page 404 @404; > location @404 { echo '{"status": "Not Found"}'; } > [..] Instead of using 3rd-party echo module, you can utilize the return directive for the same purpose: return 200 '{"status

Re: Return JSON for 404 error instead of html

2014-05-13 Thread Matthias Rieber
On Mon, 12 May 2014, Lord Nynex wrote: Justink101, Using the echo module error_page 404 @404; location @404 { echo '{"status": "Not Found"}'; } if your using proxy_pass, don't forget: proxy_intercept_errors on; Matthias ___ nginx mailing list ng

Re: Return JSON for 404 error instead of html

2014-05-12 Thread Lord Nynex
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 wrote: > How can I return a custom JSON body on 404, instead of the default html of: > > > > > 404 Not Found > > > >

Return JSON for 404 error instead of html

2014-05-12 Thread justink101
How can I return a custom JSON body on 404, instead of the default html of: 404 Not Found 404 Not Found nginx Posted at Nginx Forum: http://forum.nginx.org/read.php?2,250033,250033#msg-250033 ___