Adult Script Pro Community Forums

The forum is here for legacy reasons. No new posts will be created. User registration is disabled! If you have any questions, please email us or check https://www.adultscriptpro.com for more details!

You are not logged in.

#1 2013-04-10 08:32:04

discuss4u
Member
Registered: 2013-03-06
Posts: 163

Limit concurrent downloads

I am now turning the server. Just wonder if I should try to limit the number of concurrent downloads per ip.

If so, how should I do it??

I am using nginx

And I try to use the limit_conn_zone directive

with limit_conn directive under

location /media/videos/mp4
location /media/videos/flv
location /media/videos/mobile

and

location /tmp/downloads

I try to limit it to 2 connections at a time but I can still download more than 3 videos at a time....

Last edited by discuss4u (2013-04-10 08:37:27)

Offline

#2 2013-04-10 11:06:46

symtab
Administrator
Registered: 2010-08-23
Posts: 7,501
Website

Re: Limit concurrent downloads

Please check this: http://wiki.nginx.org/HttpLimitZoneModule

You need to limit media/videos/mp4, media/videos/flv and media/videos/mobile


Adult Scripts: Adult Script Pro - Adult Search Script
Adult Advertising/Traffic: Plug Rush - EXOClick - PopAds

Offline

#3 2013-04-10 15:43:19

discuss4u
Member
Registered: 2013-03-06
Posts: 163

Re: Limit concurrent downloads

Thanks symtab. I am still finding a way to work it out. limit_conn works perfectly under "server". But it does not work under "location" ...

But it should work under "location" according to the documents....

Offline

#4 2013-04-10 17:08:00

discuss4u
Member
Registered: 2013-03-06
Posts: 163

Re: Limit concurrent downloads

Apparently I have found a solution. limit_conn won't work if we use something like

        location /media/videos/mp4 {
                limit_conn perip 10;}

It is because Nginx will keep on searching the query and the *.mp4 files will be eventually handled by

location ~ \.mp4$ {....}

And it won't work even if we put location /media/videos/mp4 {} below location ~ \.mp4$ {....}. It is because Nginx will already handle the *.mp4 files when it finds location ~ \.mp4$ {....}.

So, there is no point to put location /media/videos/mp4 {} in the conf file unless you want to limit the connections to files other than *.mp4 in this directory.

The situation is similar for media/videos/flv and media/videos/mobile

On the other hand, we cannot use

        location ^~ /media/videos/mp4 {
                limit_conn perip 10;}

because Nginx will stop searching the query in this case.

In this case,

location ~ \.mp4$ {....}

will not be used to handle the *mp4 files and thus the secure link will not work.

So, we need to do is to add limit_conn at the end of "location ~ \.mp4$", like this.

        location ~ \.mp4$ {

            ..........

            limit_conn perip 10;
            limit_rate_after 5m;
            limit_rate 250k;

        }

Apparently this will limit to 10 connections per IP. Here, perip is just the one name I have used. Be sure to add limit_conn_zone directive under httpd directive.

I was not able to make it work just because I am not aware of how Nginx searches the queries when we use location directive. More can be found from http://wiki.nginx.org/HttpCoreModule#location

Though it is mainly an Nginx thing instead of an ASPro thing. But symtab can put this to the documentation part of the forum if you feel like to do so smile

Last edited by discuss4u (2013-04-10 18:14:11)

Offline

#5 2013-04-12 12:09:41

Jadmanx
Member
Registered: 2012-05-25
Posts: 128

Re: Limit concurrent downloads

there a better way with Iptables Limits Connections Per IP? i think i have a lot user they download the movies with a site download bot. but how much connection per ip ? 10 ? 5 ? 2 ?
see pic

39090843.jpg


Limit HTTP Connections Per IP / Host

/sbin/iptables -A INPUT -p tcp --syn --dport 80 -m connlimit --connlimit-above 20 -j REJECT --reject-with tcp-reset
# save the changes see iptables-save man page, the following is redhat and friends specific command
service iptables save

Offline

Board footer

Powered by FluxBB