2017. 4. 27. 11:32 Linux Server/apache
[apache] cband 모듈설치
[cband 모듈설치]
cband 모듈이란 도메인 별로 트래픽을 제한할수 있으며, 트래픽 사용량을 확인할 수 있다.
# tar -zxvf mod-cband-0.9.7.5.gz -> 해당 파일 압축풀기
# cd mod-cband-0.9.7.5 -> 해당 결로 이동
# ./configure --with-apxs=/usr/local/apache/bin/apxs -> 컨피그
# make -> make 시 아래처럼 에러가 발생할 가능성이 있다.
/usr/local/apache/bin/apxs -Wc,-Wall -Wc,-DDST_CLASS=3 -c src/mod_cband.c
/usr/local/apache/build/libtool --silent --mode=compile gcc -std=gnu99 -prefer-pic -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -g -O2 -pthread -I/usr/local/apache/include -I/usr/local/apache/include -I/usr/local/apache/include -Wall -DDST_CLASS=3 -c -o src/mod_cband.lo src/mod_cband.c && touch src/mod_cband.slo
src/mod_cband.c: In function 'mod_cband_create_traffic_size':
src/mod_cband.c:1054: warning: comparison with string literal results in unspecified behavior
src/mod_cband.c:1054: warning: comparison with string literal results in unspecified behavior
src/mod_cband.c:1058: warning: comparison with string literal results in unspecified behavior
src/mod_cband.c:1058: warning: comparison with string literal results in unspecified behavior
src/mod_cband.c: In function 'mod_cband_get_dst':
src/mod_cband.c:1333: error: 'conn_rec' has no member named 'remote_ip'
src/mod_cband.c: In function 'mod_cband_get_remote_host':
src/mod_cband.c:1362: error: 'struct conn_rec' has no member named 'remote_ip'
src/mod_cband.c:1363: error: 'struct conn_rec' has no member named 'remote_ip'
src/mod_cband.c:1365: error: 'struct conn_rec' has no member named 'remote_addr'
apxs:Error: Command failed with rc=65536
.
make: *** [src/.libs/mod_cband.so] 오류 1
# cd /home/les/mod-cband-0.9.7.5/src/ -> 해당 경로로 이동
# vi mod_cband.c -> 해당 파일 수정
빨간색 : 수정전
파란색 : 수정후
1333번 라인
p.add.sin.s_addr = inet_addr(r->connection->remote_ip);
p.add.sin.s_addr = inet_addr(r->connection->client_ip);
1342번 라인
fprintf(stderr,”%s leaf %s\n”,r->connection->remote_ip,leaf);
fprintf(stderr,”%s leaf %s\n”,r->connection->client_ip,leaf);
1362~1365번 라인
if (c->remote_ip != NULL)
addr = inet_addr(c->client_ip);
else
addr = c->remote_addr->sa.sin.sin_addr.s_addr;
if (c->client_ip != NULL)
addr = inet_addr(c->client_ip);
else
addr = c->client_addr->sa.sin.sin_addr.s_addr;
# make
# make install
이후에 httpd.conf 파일에 LoadModule cband_module modules/mod_cband.so 이 생성되어있을 것이다.
# vi httpd.conf -> 해당 파일 열어서 설정 값 입력
<IfModule mod_cband.c>
<Location /cband-status-me>
SetHandler cband-status-me
</Location>
<Location /~*/cband-status-me>
SetHandler cband-status-me
</Location>
<Location /cband-status>
SetHandler cband-status
Order deny,allow
Deny from all
Allow from all -> all 대신 ip 입력시 해당 ip에서만 상태페이지 접속 가능
</Location>
</IfModule>
# vi httpd-vhost.conf
<VirtualHost *>
ServerName yourdomain.com
Document /home/test/
CBandLimit 500Mi -> 500M 허용
CBandPeriod 1D -> 1일간
CBandExceededURL http://yourdomain.com/traffic_exceeded.html -> 트래픽초과시 보여지는 페이지
</VirtualHost>
이후에 yourdomain/cband-status 로 접속하시면 트래픽 사용량을 확인할 수 있습니다.
'Linux Server > apache' 카테고리의 다른 글
[apache] ssl 키 발급 및 적용 (0) | 2017.06.03 |
---|---|
[php 언어셋 문제] (0) | 2017.05.09 |
[apache] rewrite 모듈을 이용한 http -> https 포워딩 (0) | 2017.04.26 |
[apache] 모듈 userdir (0) | 2017.01.10 |
[apache] apache 소스설치 (2.4.3) (0) | 2016.09.21 |