2

I got my site up and running on nginx on my Dreamhost VPS. Cool. I wanted to limit the number of connections per IP by adding the following to the http block of the site-wide nginx conf file (/dh/nginx/servers/httpd-psxxxxxx/nginx.conf):

limit_conn_zone $binary_remote_addr zone=addr:10m;
limit_conn limit_per_ip 50;

Reloaded nginx and everything works fine and dandy.

When the server is rebooted nginx fails to startup. I have to go to the nginx file again, comment out the two lines about limiting the number of connections per IP, reload nginx, then go back and uncomment the two lines again, and then reload nginx. After that everything is fine.

If I try and manually reloading nginx after a server reboot I get the following error message:

webserver... nginx: [emerg] zero size shared memory zone "limit_per_ip"
failed!

What am I doing wrong? All I want to do is prevent a single IP from hogging all the connections and driving the RAM on my VPS through the roof which triggers a reboot.

kingkool68
  • 243
  • 3
  • 10

1 Answers1

3

The problem is that you named your zone addr but then you referred to it as limit_per_ip, which isn't the name you selected.

Either change the zone name from addr to limit_per_ip in the limit_conn_zone directive, or change the zone name from limit_per_ip to addr in the limit_conn directive.

Michael Hampton
  • 237,123
  • 42
  • 477
  • 940