nginx: How to drop connections for a location

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 About 8 years ago