How can I have nginx return 204 when send_timeout is triggered?

Maxim Dounin mdounin at
Wed Dec 10 14:13:32 UTC 2014


On Wed, Dec 10, 2014 at 08:58:42AM -0500, meir.h at wrote:

> Hello Maxim,
> I am so sorry for not being clear.
> My question is, can I have the nginx submit a 204 to the client after a
> predefined time?

Yes, but that's not a trivial task when using vanilla nginx.  For 
example you can do this using the embedded perl module, 
$r->sleep() command:

    location / {
        perl 'sub {
            my $r = shift;

            sub next {
                my $r = shift;

            $r->sleep(1000, \&next);

See for more details.

This can be also done using 3rd party modules.  E.g., using the 
delay module as available from, 
this can be done as follows:

    location / {
        delay 2s;
        error_page 403 = /empty;
        deny all;

    location = /empty {
        return 204;

Maxim Dounin

More information about the nginx mailing list