본문 바로가기

리눅스

[Apache] apache 다운로드 대역폭 속도 제한

반응형

apache 다운로드 대역폭 속도 제한

httpd.conf 편집(mod_ratelimit 모듈 활성화)

$ vim /usr/local/apache2/conf/httpd.conf
...
#LoadModule data_module modules/mod_data.so
LoadModule ratelimit_module modules/mod_ratelimit.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
#LoadModule ext_filter_module modules/mod_ext_filter.so
...

configuration 편집

$ vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
...
<VirtualHost *:80>
    ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/usr/local/apache2/docs/test.sangchul.kr"
    ServerName test.sangchul.kr
    ServerAlias t.sangchul.kr
    DirectoryIndex index.html
    CustomLog "|/usr/sbin/cronolog /logs/access/test.sangchul.kr-%Y%m%d.log" combined
    ErrorLog "|/usr/sbin/cronolog /logs/error/test.sangchul.kr-%Y%m%d.log"
    <Directory "/usr/local/apache2/docs/test.sangchul.kr">
        <LimitExcept GET POST>
                Order deny,allow
                Deny from all
        </LimitExcept>
        Require all granted
    </Directory>
    <Location "/dl">
        SetOutputFilter RATE_LIMIT
        SetEnv rate-limit 400
    </Location>
</VirtualHost>
...

아파치 버전 확인

$ /usr/local/apache2/bin/apachectl -v
Server version: Apache/2.4.29 (Unix)
Server built:   May 19 2020 11:17:30

or

$ /usr/local/apache2/bin/httpd -v
Server version: Apache/2.4.29 (Unix)
Server built:   May 19 2020 11:17:30

* 제약사항

- rate-initial-burst는 httpd 2.4.24 이상에서 사용할 수 있습니다. 

- 속도 제한 프록시 콘텐츠는 httpd 2.4.33까지 올바르게 작동하지 않습니다.

다운로드 테스트

### 원격 서버에서 cURL 테스트
$ curl -O http://test.sangchul.kr/dl/CentOS-8.2.2004-x86_64-dvd1.iso
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0 7850M    0  654k    0     0   406k      0  5:29:32  0:00:01  5:29:31  406
  
 
### 로컬 서버에서 wget 테스트
$ wget http://test.sangchul.kr/dl/CentOS-8.2.2004-x86_64-dvd1.iso
--2020-12-15 14:29:18--  http://test.sangchul.kr/dl/CentOS-8.2.2004-x86_64-dvd1.iso
Resolving test.sangchul.kr (test.sangchul.kr)... 2.2.2.2
Connecting to test.sangchul.kr (test.sangchul.kr)|2.2.2.2|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 8231321600 (7.7G) [application/x-iso9660-image]
Saving to: ‘CentOS-8.2.2004-x86_64-dvd1.iso’

 0% [                                                          ] 745,472      404KB/s 

 

httpd.apache.org/docs/2.4/mod/mod_ratelimit.html

 

mod_ratelimit - Apache HTTP Server Version 2.4

Apache Module mod_ratelimit Summary Provides a filter named RATE_LIMIT to limit client bandwidth. The throttling is applied to each HTTP response while it is transferred to the client, and not aggregated at IP/client level. The connection speed to be simul

httpd.apache.org

 

 

728x90
반응형