{"id":112,"date":"2011-12-10T16:17:00","date_gmt":"2011-12-10T16:17:00","guid":{"rendered":"http:\/\/pheonixsolutions.com\/?p=112"},"modified":"2026-06-12T08:28:04","modified_gmt":"2026-06-12T02:58:04","slug":"limit-apache-bandwidth-per-user","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/limit-apache-bandwidth-per-user\/","title":{"rendered":"Limit Apache Bandwidth Per User"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In some hosting environments, it may be necessary to limit the bandwidth usage of a specific user, domain, file type, or virtual host. Although cPanel provides account-level bandwidth limits, there may be cases where you need to control the bandwidth speed per hour, per day, or per request directly through Apache.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Apache bandwidth limiting can be done using the <code>mod_bw<\/code> module. This module allows you to control the download\/upload speed for users, domains, file extensions, large files, or specific MIME types.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before proceeding, make sure you have the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Root access to the server.<\/li>\n\n\n\n<li>Apache installed and running.<\/li>\n\n\n\n<li>cPanel\/WHM server access, if this is a cPanel-based server.<\/li>\n\n\n\n<li><code>mod_bw<\/code> module installed and enabled in Apache.<\/li>\n\n\n\n<li>Basic knowledge of Apache virtual host configuration.<\/li>\n\n\n\n<li>Backup of Apache configuration files before making changes.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Check Whether mod_bw Is Installed<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Run the following command to check whether the bandwidth module is enabled in Apache:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/usr\/local\/apache\/bin\/apachectl -M | grep mod_bw\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the module is installed and enabled, it should appear in the output.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method 1: Limit Bandwidth for a Specific cPanel User<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In this example, we will limit a user\u2019s bandwidth speed to <strong>250 KB\/s<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Go to the Apache Userdata Directory<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">For cPanel servers, it is recommended to use the custom userdata include path instead of directly editing <code>httpd.conf<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example format:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/usr\/local\/apache\/conf\/userdata\/std\/2\/USERNAME\/DOMAIN.COM\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Example:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/usr\/local\/apache\/conf\/userdata\/std\/2\/heman\/hemanth.com\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Create the Directory<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If the directory does not exist, create it:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mkdir -p \/usr\/local\/apache\/conf\/userdata\/std\/2\/heman\/hemanth.com\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Create the Bandwidth Limit Configuration File<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create a custom Apache configuration file:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">vi \/usr\/local\/apache\/conf\/userdata\/std\/2\/heman\/hemanth.com\/cp_bw_all_limit.conf\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Add the following content:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">BandWidthModule On\nBandWidth all 256000\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save and close the file.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This configuration limits the user bandwidth to approximately <strong>250 KB\/s<\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Rebuild Apache Configuration<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">After adding the custom include file, rebuild the Apache configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/scripts\/rebuildhttpdconf\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Restart Apache<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Restart Apache to apply the changes:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/scripts\/restartsrv_httpd\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Why Use the cPanel Userdata Include Path?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It is not recommended to directly edit the main <code>httpd.conf<\/code> file because changes may be overwritten during Apache rebuilds, cPanel updates, or EasyApache changes.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Using the custom userdata path ensures that the configuration remains safe and persistent after Apache rebuilds or upgrades.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method 2: Limit Every User on a Virtual Host to 10 KB\/s<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use the following configuration to limit every user on a virtual host to a maximum speed of <strong>10 KB\/s<\/strong>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">BandwidthModule On\nForceBandWidthModule On\nBandwidth all 10240\nMinBandwidth all -1\nServerName www.example.com\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Method 3: Limit Internal LAN Users<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The following configuration limits all internal users to <strong>1000 KB\/s<\/strong>, with a minimum bandwidth of <strong>50 KB\/s<\/strong>. It also limits files greater than <strong>500 KB<\/strong> to <strong>50 KB\/s<\/strong>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">BandwidthModule On\nForceBandWidthModule On\nBandwidth all 1024000\nMinBandwidth all 50000\nLargeFileLimit * 500 50000\nServerName www.example.com\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Method 4: Limit Specific File Extensions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To limit <code>.avi<\/code> and <code>.mpg<\/code> files to <strong>20 KB\/s<\/strong>, use the following configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">BandwidthModule On\nForceBandWidthModule On\nLargeFileLimit .avi 1 20000\nLargeFileLimit .mpg 1 20000\nServerName www.example.com\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Method 5: Limit Bandwidth by MIME Type<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can also limit bandwidth based on MIME type using Apache output filters.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example: Limit text-based content such as HTML and plain text to <strong>5 KB\/s<\/strong>:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">BandwidthModule On\nAddOutputFilterByType MOD_BW text\/html text\/plain\nBandwidth all 5000\nServerName www.example.com\n<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Apache bandwidth limiting can be configured using the <code>mod_bw<\/code> module to control traffic speed for specific users, domains, virtual hosts, file extensions, large files, or MIME types.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For cPanel servers, it is always recommended to place custom Apache configurations inside the userdata include path instead of directly editing <code>httpd.conf<\/code>. This helps preserve the configuration during Apache rebuilds, EasyApache updates, and cPanel upgrades.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">After making any changes, rebuild the Apache configuration and restart Apache to apply the bandwidth limits.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction In some hosting environments, it may be necessary to limit the bandwidth usage of a specific user, domain, file [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[],"class_list":["post-112","post","type-post","status-publish","format-standard","hentry","category-web-architecture","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-1O","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=112"}],"version-history":[{"count":1,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/112\/revisions"}],"predecessor-version":[{"id":10349,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/112\/revisions\/10349"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}