독까의 이야기

웹호스팅 서비스를 제공하기 위해서는 필수적으로 각 웹사이트에 대한 트래픽 제한이 필요하다. 

apache 에 적용 가능한 트래픽 및 대역폭 제한 모듈인 cband  설치 테스트를 진행 하였다. 


테스트 환경 : 

OS : CentOS release 6.9 (Final)

Apache : Apache/2.2.15 (Unix)



1.  cbnad 모듈 설치.


설치 경로로 이동

# cd /usr/local 


wget 을 이용하여 설치 파일 다운로드

# wget http://cband.linux.pl/download/mod-cband-0.9.7.4.tgz 


하였는데, 다운로드가 실패 한다. 

개발 웹사이트가 폐쇄되어 파일 다운로드 불가하다. 


다른 사이트에서 다운로드 받은 후에 설치 경로에 파일 업로드 한다. 


http://linux.softpedia.com/get/Internet/HTTP-WWW-/mod-cband-4737.shtml#download


압축 해제 및 경로 진입

# tar xvfpz mod-cband-0.9.7.5.tgz

# cd mod-cband-0.9.7.5 



configure 실행

# ./configure --with-apxs=/usr/sbin/apxs 


생성 실패한다. 


로그를 확인해 본다. 

configure:1340: checking for gcc

configure:1369: result: no

configure:1420: checking for cc

configure:1449: result: no

configure:1462: checking for cc

configure:1508: result: no

configure:1561: checking for cl

configure:1590: result: no

configure:1604: error: no acceptable C compiler found in $PATH 


gcc 가 설치가 되어 있지 않아서 발생하는 오류 이므로 설치를 진행 한다. 

# yum install gcc -y


gcc 설치도 했으니 다시 configure 실행한다.

# ./configure --with-apxs=/usr/sbin/apxs 


다른 에러가 나온다. 

configure: error: Invalid location for apxs: '/usr/sbin/apxs 


원인 : apsx 경로 확인 불가


apsx 경로를 찾기 위해 명령어를 입력한다. 

# find / -name "apxs" -print 


아무런 결과도 출력되지 않는다. 


yum 을 이용해 apache 를 설치 했기 때문에, apsx 미등록 상태 였다. 


httpd-devel 패키지 설치를 진행한다. 

# yum install httpd-devel -y  


경로 재확인

# find / -name "apxs" -print

/usr/sbin/apxs 


configure 및 make 실행

# ./configure --with-apxs=/usr/sbin/apxs

# make

# make install 


정상적으로 설치가 되었음을 확인했다. 

chmod 755 /usr/lib64/httpd/modules/mod_cband.so

[activating module `cband' in /etc/httpd/conf/httpd.conf] 



2. cbnad 설정 파일 생성.


httpd.conf 에 직접 설정을 추가해도 되지만, 관리의 용이성을 위하여 개별 설정 파일을 만든다. 


# vi /etc/httpd/conf.d/cband.conf


<IfModule mod_cband.c>

        <Location /cband-status>

                SetHandler cband-status

        </Location>

        <Location /cband-status-me>

                SetHandler cband-status-me

        </Location>

        <Location /~*/cband-status-me>

                SetHandler cband-status-me

        </Location>

        <Location /cband-status>

                Order deny,allow

                Deny from all

                Allow from 192.168.1.100/32   // 관리 페이지 접근 허용 아이피

        </Location>

</IfModule> 



3. vhost 설정 


모듈 적용이 필요한 웹사이트의 vhost 를 수정한다. 

(일일 트래픽 용량 5G 로 제한)

# vi /etc/httpd/conf/httpd.conf


<VirtualHost *:80>

ServerName gunnm.xyz

ServerAlias www.gunnm.xyz

Documentroot /var/www/html

CBandLimit 5000M

CBandPeriod 1D

</VirtualHost> 


서비스 재시작

# service httpd restart 


웹브라우저에서 설정 확인

gunnm.xyz/cband-status




추가 옵션값은 아래의 링크에서 확인이 가능하다. 설명이 상세히 잘 되어 있다. 

https://www.linux.co.kr/home/lecture/?leccode=10588