To provide connection limiting, we first need to define a shared memory space to use for tracking. This needs to be done outside of the server directive and generally placed in the main NGINX configuration file (nginx.conf). Here's our directive:
limit_conn_zone $binary_remote_addr zone=conlimitzone:10m;
Then, we incorporate this into our server block directive:
server { listen 80; server_name limitcon.nginxcookbook.com; access_log /var/log/nginx/limitcon.log combined; location / { root /var/www/html; limit_conn conlimitzone 1; limit_rate 5m; index index.html index.htm; } }
We can confirm this by downloading a large file via the browser and then opening another tab. If you navigate to any other page from the same site, you should see the following:

Until the first request is completed, all subsequent attempts will display a 503 error.