To limit the number of connections: Use the limit_conn_zone directive to define the key and set the parameters of the shared memory zone (the worker processes will use this zone to share counters for key values). ... Use the limit_conn directive to apply the limit within the location {} , server {} , or http {} context.