How can I limit the total speed of a port or domain name?

You know,the ngx_http_limit_zone_module can limit the speed of an IP .

I want to limit the total speed of a port or a domain name.

For example:
There was a Server(the all speed is limited by the IDC 10M/s).
There was a Nginx on the Server.
There was two port for this Nginx—> 8080 and 8090,now I want to limit
the
total speed of 8090 to 5M/s,No matter how match ip,No matter how match
conn
per IP.

Posted at Nginx Forum:

On Wed, Apr 03, 2013 at 09:58:57PM -0400, tssungeng wrote:

Hi there,

You know,the ngx_http_limit_zone_module can limit the speed of an IP .

Can it?

If you can show your configuration that does that, then it should be
straightforward to modify it to use the server port or server name
instead of the ip address as the controlling variable.

I’m not aware of a stock-nginx way of limiting speed, other than
per-request.

f

Francis D. [email protected]

centos5.5 + nginx-1.3.14

I use the limit_speed_zone
(GitHub - yaoweibin/nginx_limit_speed_module: limit the total speed from the specific user),and set the
nginx.conf:

http {
limit_speed_zone one $server_port 10m;
server {
listen 8080;
server_name localhost;
location / {
root /opt/case/web/www;
index index.html index.htm index.php;
limit_speed one 10k;
}
}
}

The uper setting can limit the speed to 10K per IP.

and then ,i try the HttpLimitConnModule:

http {
limit_conn_zone $server_port zone=addr:10m;
server {
listen 8080;
server_name localhost;
location / {
root /opt/case/web/www;
index index.html index.htm index.php;
limit_rate 20k;
}
}
}

The uper setting can limit the speed to 20K per connetction.and if a IP
open
5 thread for conn,then ,the IP can download 100K/s from my nginx.

the nginx.conf of my Nginx with some error?

Posted at Nginx Forum:

How do you test the limit_speed module? It works in my test box.

Thanks.

2013/4/5 tssungeng [email protected]

On Thu, Apr 04, 2013 at 10:29:01PM -0400, tssungeng wrote:

Hi there,

I use the limit_speed_zone
(GitHub - yaoweibin/nginx_limit_speed_module: limit the total speed from the specific user),and set the
nginx.conf:

Ok, this third party module looks like it should do what you want,
according to its description.

}

}

The uper setting can limit the speed to 10K per IP.

I don’t see anything there which says “per IP”.

It looks like what is above will limit the speed per server_port, which
is one of the things you wanted.

Does it not work for you?

What does it do?

and then ,i try the HttpLimitConnModule:

That can limit the number of connections, not the speed directly.

http {
limit_conn_zone $server_port zone=addr:10m;

Here you define this zone, but you don’t have any limit_conn directive
to use the zone, so you have no limit on the number of connections.

The uper setting can limit the speed to 20K per connetction.and if a IP open
5 thread for conn,then ,the IP can download 100K/s from my nginx.

Yes, that’s what limit_rate is expected to do.

the nginx.conf of my Nginx with some error?

The third-party module config looks like it should be right, and should
do what you want. The stock module config won’t do what you want.

f

Francis D. [email protected]