Limit per-user network speed in Vesta Control Panel

In this tutorial you will learn how you can set different internet usage or speed limits per website/user as well as how to limit connections, different speed on different file sizes. This tutorial is meant for Vesta Control Panel.

We will be using mod_bw to limit the speeds and the mod is made for Apache but works on Apache + Nginx as reverse proxy too.

mod_bw for Apache Bandwidth module allows you to limit the internet speed on a per-VirtualHost basis, which is very useful for web hosting companies (many sites on a single IP) or for managing the speed of websites.

Requirements

  • CentOS/Ubuntu
  • Apache/Apache + Nginx
  • Basic Administration Knowledge
  • 10 Minutes

Installation

Installation commands for boht CentOS and Ubuntu have been provided.


Installation for CentOS

Enter the following command if you are on CentOS

yum install mod_bw; apachectl -k graceful

Installation for Ubuntu

Enter the following command if you are on CentOS

sudo apt-get install libapache2-mod-bw; sudo a2enmod bw

Now that mod_bw has been installed, we need to edit the httpd.conf file of every website to limit the speed.

The basic structural location for httpd.conf/apache2.conf file for every website is /home/user/conf/web

Open the httpd.conf or apache2.conf file.

You will see a line  <Directory /home/user/web/domain.tld/public_html>

Add the following lines below it

BandWidthModule On
ForceBandWidthModule On
BandWidth all 122880
BandWidthError 510
AllowOverride all
Require all granted

In the line Bandwidth all 122880 allocates 120Kb/s (122880/1024) to every user who connects to that particular website. This means that every user will not be able to take more than 120Kb/s internet speed from that website.

ForceBandWidthModule On forces the module to apply to every request. By default the mod isn’t applied to every user so, this line will force the mod to work for every user.

Another line MinBandwidth all 10240 can be added to allocate a minimum bandwidth of 10 Kb/s to every user.

MaxConnection all 30 can be added to the above to limit the number of connections to a website to 30 or any other specified number. This is useful for shared hosting providers or a server with multiple websites to control or limit the total speed of every website.

 

yoast seo premium free
%d bloggers like this: