How to ratelimit for user in apache2?

Hello,
I am running ubuntu14.04
I am able to limit download speed for www-data but for a user, for example boris, somehow it's not working with low download speed.

Here is what I did:

adduser boris
sudo a2enmod userdir
chmod -R 755 /home/boris
#chmod -R 755 /home/boris/public_html
#chmod -R 755 /home/boris/public_html/category

When I start the download process, it gives 30Mbps download speed with:

wget http://public_ip/~boris/category/1.iso

To limit download speed:

a2enmod ratelimit
#created ratelimit.conf
nano /etc/apache2/conf-available/ratelimit.conf

#added below lines into ratelimit.conf:

<IfModule mod_ratelimit.c>
	<Location /~boris/category>
		SetOutputFilter RATE_LIMIT
		SetEnv rate-limit 1000
	</Location>
</IfModule>

#ratelimit activation:

a2enconf ratelimit
#apache2 reload
service apache2 restart

After apache is restarted, it gives the same speed but I supposed to get max 8Mbps.
Normally it works as expected with low download speed when the file is under /var/www/html/

I also tried below conf:

<IfModule mod_ratelimit.c>
	<Location /home/boris/public_html/category>
		SetOutputFilter RATE_LIMIT
		SetEnv rate-limit 1000
	</Location>
</IfModule>

but nothing changed.

Could you please let me know what is wrong?

Edit: Sorted out this way:

<IfModule mod_ratelimit.c>
	<Location /~boris/category>
		SetOutputFilter RATE_LIMIT
		SetEnv rate-limit 1000
	</Location>
</IfModule>

Thanks
Boris

1 Like

Dear Boris,

Thank you for updating your post with your solution.

Glad you got things sorted and it's working as expected now.