Skip to content

Nginx Module Options

Andrew Rodland edited this page Feb 24, 2014 · 3 revisions

smockron

Syntax: smockron [on|off]

Default: off

Context: http, server, location

Enables or disables rate-limiting for a given block. Smockron will not process requests in a block where it is disabled.

smockron_master

Syntax: smockron_master scheme://server:port

Default: tcp://localhost:10004

Context: http, server, location

The location of the smockron master server to connect to. Must follow the rules of a ZeroMQ connection string and must include a port number. The accounting connection will be made on the named port, and the control connection will be made on the port one higher.

smockron_domain

Syntax: smockron_domain domainname

Default: default

Context: http, server, location

The smockron domain for requests to this block. Domains allow a smockron server to control access to more than one resource; resources which should be rate-limited independently should have different domains.

smockron_identifier

Syntax: smockron_identifier $variable

Default: $remote_addr

Context: http, server, location

Specifies the variable used to identify clients for rate limiting. $remote_addr is a good default, but you might want to use something like $http_x_real_ip if behind a proxy, or a custom variable containing an API key. An identifier of "" or any constant string allows you to limit the total traffic to a resource.

smockron_log_info

Syntax: smockron_log_info $variable

Default: none

Context: http, server, location

A variable containing extra info to send to the smockron master for logging. Unset by default, and currently the master does nothing with this information.

smockron_max_delay

Syntax: smockron_max_delay msec

Default: 5000

Context: http, server, location

The maximum time to delay a request before rejecting it. If a client's next request will be allowed less than smockron_max_delay milliseconds in the future it will be delayed until that time; otherwise it will be rejected.

smockron_status_code

Syntax: smockron_status_code code

Default: 503

Context: http, server, location

The status code to use for rejected requests. The default, 503, is encouraged by the HTTP RFC for an overloaded server. Can be used in connection with the nginx error_page option.

smockron_shm_size

Syntax: smockron_shm_size nnn[K|M]

Default: 4M

Context: http

The size of the shared memory area used to store throttled clients for the entire server. The default should be enough for a moderately busy server, but if you receive "Allocating delay failed, increase smockron_shm_size" or "HASH_ADD_STR failed, increase smockron_shm_size" messages, then increase this value until they go away. If the shared memory area becomes full, additional clients can't be throttled, and will be allowed access.