nginx: How to drop connections for a location

Posted . Visible to the public.

If you want to configure your nginx to drop connections to a specific location, you can do so by responding with HTTP response code 444.

Status 444 is a non-standard response code that nginx will interpret as "drop connection".

Example:

server {
  listen 127.0.0.1;
  
  location /api/ {
    return 444;
  }
}

An example use case is reverse-proxying with nginx and simulating a route that drops connections.

Arne Hartherz
Last edit
Arne Hartherz
Keywords
close, connection
License
Source code in this card is licensed under the MIT License.
Posted by Arne Hartherz to makandra dev (2016-03-02 13:25)