在apache主机上限制下载速度的简单方法是什么?

在apache主机上限制下载速度的简单方法是什么?,apache,Apache,我正在尝试一些东西,我需要从我的网站下载一个低速文件(比如10KBps)。有没有简单的方法可以在服务器或主机上仅为特定目录设置限速器?您没有说您正在使用什么工具或操作系统,但是curl有一个选项可以限制它使用的带宽: curl --limit-rate 200K 您不会说您正在使用什么工具或操作系统,但是curl有一个选项来限制它使用的带宽: curl --limit-rate 200K Apache有一个为此目的设计的mod\u rate limit。Apache有一个mod\u rate

我正在尝试一些东西,我需要从我的网站下载一个低速文件(比如10KBps)。有没有简单的方法可以在服务器或主机上仅为特定目录设置限速器?

您没有说您正在使用什么工具或操作系统,但是
curl
有一个选项可以限制它使用的带宽:

curl --limit-rate 200K

您不会说您正在使用什么工具或操作系统,但是
curl
有一个选项来限制它使用的带宽:

curl --limit-rate 200K

Apache有一个为此目的设计的
mod\u rate limit

Apache有一个
mod\u rate limit
为此目的设计。

使用httpd包中包含的模块
mod_rate limit

以下是CentOS 7上的一个实现:

  • 启用
    mod\u rate limit
    模块:

    vi /etc/httpd/conf.modules.d/00-base.conf
    
    取消注释第72行:

    LoadModule ratelimit_module modules/mod_ratelimit.so  
    
  • mod\u ratelimit
    创建配置文件:

    vi /etc/httpd/conf.d/ratelimit.conf  
    
    然后将此内容放入:

    #limit bandwidth as 500KB/sec under the [apache_DocumentRoot_directory]/specific_directory
    <IfModule mod_ratelimit.c>
            <Location /specific_directory>
                SetOutputFilter RATE_LIMIT
                SetEnv rate-limit 500
            </Location>
    </IfModule>
    
  • 使用httpd包中包含的模块
    mod_rate limit

    以下是CentOS 7上的一个实现:

  • 启用
    mod\u rate limit
    模块:

    vi /etc/httpd/conf.modules.d/00-base.conf
    
    取消注释第72行:

    LoadModule ratelimit_module modules/mod_ratelimit.so  
    
  • mod\u ratelimit
    创建配置文件:

    vi /etc/httpd/conf.d/ratelimit.conf  
    
    然后将此内容放入:

    #limit bandwidth as 500KB/sec under the [apache_DocumentRoot_directory]/specific_directory
    <IfModule mod_ratelimit.c>
            <Location /specific_directory>
                SetOutputFilter RATE_LIMIT
                SetEnv rate-limit 500
            </Location>
    </IfModule>