{"id":457,"date":"2011-03-11T05:25:25","date_gmt":"2011-03-11T11:25:25","guid":{"rendered":"http:\/\/blog.supportpro.com\/?p=457"},"modified":"2026-03-24T23:50:57","modified_gmt":"2026-03-25T05:50:57","slug":"limit-apache-bandwidth-using-mod-bw-module","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/limit-apache-bandwidth-using-mod-bw-module\/","title":{"rendered":"How to restrict number of connections per vhost\/dir and limit the bandwidth for files"},"content":{"rendered":"\n<p>Managing server resources efficiently is essential for maintaining performance and stability. If a particular domain or directory is consuming excessive bandwidth, you can control its usage using the <strong>mod_bw<\/strong> module in Apache.<\/p>\n\n\n\n<p>The <strong>mod_bw (bandwidth module)<\/strong> allows administrators to restrict bandwidth usage and limit the number of simultaneous connections for specific virtual hosts (vhosts) or directories. This is especially useful in shared hosting environments where resource control is critical.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>When to Use mod_bw<\/strong><\/h2>\n\n\n\n<p>You can use <strong>mod_bw<\/strong> when:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A domain is consuming high bandwidth<\/li>\n\n\n\n<li>Want to limit download speeds for files<\/li>\n\n\n\n<li>Need to restrict simultaneous connections<\/li>\n\n\n\n<li>Want better control over server resource usage<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Steps to Install and Configure mod_bw<\/strong><\/h2>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Check Apache Version<\/strong><\/h3>\n\n\n\n<p>Run the following command to verify your Apache version:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/local\/apache\/bin\/httpd -v<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Download the mod_bw Module<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>cd \/usr\/src<br>wget http:\/\/ivn.cl\/files\/source\/mod_bw-0.92.tgz<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Extract the Package<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>tar -zxf mod_bw-0.92.tgz<br>cd mod_bw<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. Review Configuration Instructions<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>cat mod_bw.txt | more<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. Install the Module<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/local\/apache\/bin\/apxs -i -a -c mod_bw.c<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>6. Create Configuration File<\/strong><\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>cat mod_bw.txt | perl -pe 's:^:# :g' &gt; \/usr\/local\/apache\/conf\/mod_bw.conf<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>7. Verify Module Configuration<\/strong><\/h3>\n\n\n\n<p>Edit the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/local\/apache\/conf\/mod_bw.conf<\/code><\/pre>\n\n\n\n<p>Ensure the following entries are enabled:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>LoadModule bw_module modules\/mod_bw.so&lt;Location \/modbw&gt;<br>    Order deny,allow<br>    Deny from all<br>    Allow from 127.0.0.1<br>    SetHandler modbw-handler<br>&lt;\/Location&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>8. Update Apache Main Configuration<\/strong><\/h3>\n\n\n\n<p>Open:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/local\/apache\/conf\/httpd.conf<\/code><\/pre>\n\n\n\n<p>Make sure these lines are present and enabled:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>LoadModule bwlimited_module modules\/mod_bwlimited.so<br>Include \"\/usr\/local\/apache\/conf\/mod_bw.conf\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>9. Add Configuration to Domain (vhost)<\/strong><\/h3>\n\n\n\n<p>In the Apache configuration, include mod_bw settings for the specific domain:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Include \"\/usr\/local\/apache\/conf\/userdata\/std\/2\/username\/domainname.com\/mod_bw.conf\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>10. Configure Bandwidth Limits<\/strong><\/h3>\n\n\n\n<p>Create or edit the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/usr\/local\/apache\/conf\/userdata\/std\/2\/username\/domainname.com\/mod_bw.conf<\/code><\/pre>\n\n\n\n<p>Add the following configuration:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">BandwidthModule On<br>ForceBandWidthModule On<br>Bandwidth all 100000<br>MinBandwidth all -1<\/pre>\n\n\n\n<p><strong>Explanation:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Bandwidth all 100000<\/code> \u2192 Limits bandwidth to ~100 KB\/s<\/li>\n\n\n\n<li><code>MinBandwidth all -1<\/code> \u2192 No minimum bandwidth restriction<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>11. Restart Apache<\/strong><\/h3>\n\n\n\n<p>Apply the changes by restarting Apache:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/etc\/init.d\/httpd graceful<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Conclusion<\/strong><\/h2>\n\n\n\n<p>Using <strong>mod_bw<\/strong> in Apache is an effective way to control bandwidth usage and limit connections for specific domains or directories. By implementing these configurations, you can prevent resource abuse, improve server performance, and ensure fair usage across hosted applications.<\/p>\n\n\n\n<p>For optimal results, always monitor your server after applying limits and adjust the configuration based on your requirements.<\/p>\n\n\n\n<p>If you require help, <a href=\"https:\/\/www.supportpro.com\/requestquote.php\">contact SupportPRO <\/a><\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile is-vertically-aligned-center has-white-background-color has-background\"><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\">Facing issues? <\/p>\n\n\n\n<p class=\"has-large-font-size\">Our technical support<br>engineers can solve it. <\/p>\n\n\n\n<!--HubSpot Call-to-Action Code --><span class=\"hs-cta-wrapper\" id=\"hs-cta-wrapper-3350a795-db50-482f-9911-301930d1b1be\"><span class=\"hs-cta-node hs-cta-3350a795-db50-482f-9911-301930d1b1be\" id=\"hs-cta-3350a795-db50-482f-9911-301930d1b1be\"><!--[if lte IE 8]><div id=\"hs-cta-ie-element\"><\/div><![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/3350a795-db50-482f-9911-301930d1b1be\" ><img decoding=\"async\" class=\"hs-cta-img\" id=\"hs-cta-img-3350a795-db50-482f-9911-301930d1b1be\" style=\"border-width:0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/3350a795-db50-482f-9911-301930d1b1be.png\"  alt=\"Contact Us today!\"\/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '3350a795-db50-482f-9911-301930d1b1be', {\"useNewLoader\":\"true\",\"region\":\"na1\"}); <\/script><\/span><!-- end HubSpot Call-to-Action Code -->\n<\/div><figure class=\"wp-block-media-text__media\"><img fetchpriority=\"high\" decoding=\"async\" width=\"904\" height=\"931\" src=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png\" alt=\"guy server checkup\" class=\"wp-image-12943 size-full\" srcset=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png 904w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-291x300.png 291w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-768x791.png 768w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-585x602.png 585w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Managing server resources efficiently is essential for maintaining performance and stability. If a particular domain or directory is consuming excessive bandwidth, you can control its usage using the mod_bw module&hellip;<\/p>\n","protected":false},"author":4,"featured_media":16537,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[4,7,3],"tags":[],"class_list":["post-457","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server-security","category-server-tweaking","category-technical-articles"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/457","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=457"}],"version-history":[{"count":12,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/457\/revisions"}],"predecessor-version":[{"id":16539,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/457\/revisions\/16539"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media\/16537"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=457"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=457"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=457"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}