Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Howto: the minimal server to serve zero length answers

I face funny problem: I have an FreeBSD 8.2 server, and I need to set up web server that wil answer zero (0) length answer to any request. Just '200 OK' and zero body.

Ok, I can setup nginx (and already did that) and set 404 error document to /dev/null, but I think maybe there is more optimal and elegant solution? I know there is nginx module that output 1x1 gif, may there be anything like that for zero-length file?

like image 812
Alexander Avatar asked Dec 29 '25 20:12

Alexander


1 Answers

It's possible to return a status code from Nginx:

location /empty {
  return 200;
}

NOTE Generally, HTTP status code 204 No Content is meant to say "I've completed the request, but there is no body to return". You may return it in the same fashion:

location /empty {
  return 204;
}
like image 88
Alexander Azarov Avatar answered Jan 01 '26 13:01

Alexander Azarov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!