Configurating modules
Installation
Configure nginx with --add-module=PATH where PATH points to location where you have mod_limit_proxy unpacked.
After you build nginx, module source can be deleted, but it is adviced that you keep source, in case you need to build nginx again.
Configuration
Content bellow can be also found in configuring_system.txt located in /doc/ directory of local and main server
source
Local variables
$limit_proxy_xuid
$limit_proxy_xuid holds userID used by servers to distinguish users.
This might be whatever you want, with length up to 255 characters.
If you aren't using userID feature, set this to -1 .
$limit_proxy_xuid is shared between module and filter.
Example
set $limit_proxy_xuid "-1";
if ($query_string ~* "id=(\d+)" ) {
set $limit_proxy_xuid $1;
}
This will set userID using GET argument id from query string.
Please refer to nginx documentation for possible build-in variables you can use.
$limit_proxy_host
Added in versions released after 23-10-2009
$limit_proxy_host holds destination of request or any similar data. It's used by
servers to distinguish different virtual servers or files.
$limit_proxy_host is shared between module and filter.
Example
set $limit_proxy_host $host$uri;
This will set host to real host (virtual server) and concatenate it with request filename.
Please refer to nginx documentation for possible build-in variables you can use.
Limit proxy module
This module checks incoming request and blocks those violating rules.
Configuration options include:
limit_proxy
This sets module to be active. It must be set after any other modules to work.
limit_proxy_check_server_timeout TIMEOUT
This sets timeout for connections (in miliseconds). If timeout occurs, connection will be dropped with 500 Internal Server Error.
You may use nginx like time format.
Default timeout is 1 second.
limit_proxy_check_server_path PATH
If specified, unix sockets will be used instead of tcp.
PATH is path to the socket that should be used.
limit_proxy_check_server_ip IP
This is local server ("limit server") ip. While it can point to different server,
it is vital for this connection to be fast.
Default IP is "127.0.0.1"
limit_proxy_check_server_port PORT
This is local server port.
Default port is 12000
limit_proxy_connections_limit CONNECTION_LIMIT
This sets total parallel connections that can be established between module and limit server.
If connection is required and limit is reached, server will drop request with 500 Internal Server Error
Default limit is 10000
Additionally, you can define up to 254 traffic zones. Zone numbers starts from 1 and ends with 254.
limit_proxy_traffic_zone ZONE_INDEX LIMIT_RATE LIMIT_RATE_AFTER
ZONE_INDEX is zone id
LIMIT_RATE is bandwidth, same as limit_rate from nginx configuration.
LIMIT_RATE_AFTER is amount of data downloaded after which limit rate will be used. Similar to limit_rate_after.
Due to nginx configuration being defunct in this matter, third parameter (LIMIT_RATE_AFTER) is now unused. You should
set it to zero.
Traffic filter
Sole purpose of filter is to collect amount of data transferred to user and forward it to local server. If you are using only DENY/ALLOW rules, you do not need to start this module.
Configuration options include:
traffic on/off
If set to on, filter will be used.
traffic_check_server_timeout TIMEOUT
This sets timeout for connections (in miliseconds). If timeout occurs, connection
will be dropped with 500 Internal Server Error. You may use nginx like time format.
Default timeout is 1 second.
traffic_check_server_path PATH
If specified, Unix Sockets will be used instead of TCP.
PATH is path to the socket that should be used.
traffic_check_server_ip IP
This is local server ("limit server") ip. While it can point to different server,
it is vital for this connection to be fast, but not as important as in module.
Both module and traffic should use same local server, but this is not mandatory.
Default IP is "127.0.0.1"
traffic_check_server_port PORT
This is local server port.
Default port is 12000
traffic_check_connections_limit CONNECTION_LIMIT
This sets total parallel connections that can be established between module and limit server.
If connection is required and limit is reached, server will drop request with 500 Internal Server Error.
This is different from same module variable, it means that, server will establish up to limit_proxy_connections_limit + traffic_check_connections_limit connections with local server.
Default limit is 10000
traffic_check_chunk_size SIZE
Added in versions released after 23-10-2009
This sets amount of data after which nginx informs local server. Normally, packet is send after entire data is written or connection is aborted.
This is however wrong, if you are serving huge files. It is advised to set this to relatively huge value (like 100M).
If set to zero, will send packet after data is written or connection is aborted.
Default size is 0 (not using)
|