웹서버 스트레스 테스트

리눅스/APACHE|2015. 1. 16. 16:44
반응형

웹서버 스트레스 테스트

 

방법 1.
    

    - ab 사용법 
         -n requests 요청을 수행할 개수 
         -c concurrency 요청을 만들 개수로 동시 사용자 개념  
         -v verbosity 얼마나 자세한 정보를 화면에 출력해 줄 것인지 결정 
         -w HTML 문서형식으로 테이블로 만들어 결과를 화면에 출력 
         -k HTTP 프로토콜의 지속연결 (KeepAlive) 기능을 사용 
 
        ./ab -n 100 -c 10 http://www.xxxxx.com:80/ 
        10 명의 유저가 동시에 http://www.xxxxx.com/index.html 을 요청 
        각각의 시뮬레이트 유저는 요청을 10 번씩 하게 됩니다. 
 
        ab -n 1500 -c 50 http://www.xxxxx.com:80/ 
        요청을 30 x 50 (50 명의 사용자가, 각각 30 번의 요청)

 

방법 2.


     가끔 네트웍 카드를 테스트 해야 할 경우가 있는데, 이 때 최대로 트래픽을 주는 방법입니다. 
     우선 순수하게 네트웍 트래픽만을 이용하여 부하를 줘야 하기 때문에 disk나 기타 다른 IO장 
     치의 영향을 최소화 해야 합니다. 이를 위하여 /dev/zero와 /dev/null 가상 장치를 이용 합니다. 
 
     우선 테스트 할 기계를 A라고 하고 그 상대로 B라는 기계를 준비 합니다. 물론 B는 A보다 적어도 
     많은 밴드위스를 지원하는 네트웍 카드가 장착 되어 있어야 하겠죠.

 

    1. A와 B 모두 rsh이 가능 하도록 .rhost등을 설정 합니다. 
 
    2. B로 root로긴 하여 다음 명령을 실행 합니다. 
 
          # dd if=/dev/zero | rsh A dd of=/dev/null &

         최대의 부하를 주기 위해 위 명령을 두 세번 반복 합니다.

 

    3. A로 로긴 하여 netstat -i 명령으로 트래픽을 확인 하실 수 있습니다. 
 
         # netstat -i 1 
         input le0 output input (Total) output 
         packets errs packets errs colls packets errs packets errs colls 
         825933 0 606554 0 0 853023 0 633644 0 0 
         730 0 366 0 0 730 0 366 0 0 
         848 0 427 0 0 848 0 427 0 0 
         815 0 413 0 0 815 0 413 0 0 
         849 0 425 0 0 849 0 425 0 0 
         868 0 436 0 0 868 0 436 0 0 
         862 0 432 0 0 862 0 432 0 0 
 
     위의 결과 10Mbps 인터페이스인 le0 의 in + out 패킷은 초당 평균 약 1300개 정도이고 
     이것은 1300 * 1500Bytes (MTU) = 1.95MBytes/s 가 되겠네요. 이를 다시 bps로 바꾸면 
     15.6Mbps 가 되고 full duplex이므로 괜찮은 throughput 이라고 할 수 있습니다. 
 
     4. 확인이 끝났으면 B에 실행 되고 있던 백그라운드 작업을 kill 명령으로 종료 시킵니다. 


방법3 (프로그램 툴사용) siege

 

    시즈의 특징 
 
     '시즈’라는 이름은 이 툴의 모든 것을 말한다. 서버를 에워싸 서버가 어떤 이유로 문제를 
     일으켰는지를 보여주는 것이다. 유닉스 기반의 명령행 기반 툴인 시즈는 GNU GPL 오픈소스 
     라이선스를 따르기 때문에 사용, 수정, 배포가 모두 무료다. 
 
     시즈는 단일 URL의 부하 테스트는 물론 많은 URL을 메모리로 불러들여 사용자가 설정한 
     시뮬레이션 유저만큼의 부하를 동시에 테스트할 수 있다. 또한 기록된 총히트수와 전송된 
     바이트수, 반응시간, 병행성(Concurrency), 리턴 상태 등을 보여주며, HTTP 1.0/1.1 프로토콜, 
     GET/POST 디렉티브, 쿠키, 트랜잭션 로깅, 기본적인 인증 등을 지원한다
 
     builder.com 사이트에서 다운로드

     tar zxvf siege-latest.tar.gz
     ./configure
     make
     make install

 

    - 실행하기 
 
     시즈는 웹서버를 테스트하는 다양한 옵션을 제공한다. 가장 간편한 실행 방법은 단일 URL 
     테스트다. 이것은 특정 페이지가 대량 트래픽에 어떻게 반응하는지를 잘 보여준다. 이때 
     중요한 옵션 두 가지가 동시 접속자수(-c 옵션, 디폴트는 10)와, 반복 쿼리수 혹은 시간으로 
     표현되는 테스트 기간(-t)이다. 예를 들어 25명이 동시에 1분간 접속하는 환경이라면 다음과 
     같이 실행하면 된다. 
 
     $ siege -c25 -t1M [테스트될 주소](www.naver.com)

 

 

[출처] 잡동사니 | 풍운아 (http://blog.paran.com/bandi2030/21544231)

반응형

댓글()

mod_rewrite 를 이용한 주소 단축

리눅스/APACHE|2015. 1. 16. 16:44
반응형

DocumentRoot 디렉토리에 .htaccess 파일을 생성하여 아래내용을 삽입합니다.
- 또는 apache 의 httpd.conf 에 추가해도 됩니다. (모든 사이트 적용)

- virtualhost 안에 설정도 가능합니다. (개별적 사이트 적용)

 

예1) http://sysdocu.tistory.com/11 입력시 http://sysdocu.tistory.com/aa/bb/11 의 페이지가 보이게 설정

 

        RewriteEngine on
        RewriteRule ^([a-zA-Z0-9_-]+)$ /aa/bb/$1 [L]

 

예2) http://sysdocu.tistory.com/11 입력시 http://sysdocu.tistory.com/list.php?action=search&search_type=id&search+word=11 의 페이지가 보이게 설정
 

        RewriteEngine on
        RewriteRule ^([a-zA-Z0-9_-]+)$ /list.php?action=search&search_type=id&search_word=$1 [L]

 

- 위 두개 예의 룰은 같은 형식입니다.

- 위 룰을 적용시키면 /11 뿐만 아니라 /abc 등 아무 문자가 와도 입력한 문자를 따라갑니다.

- 주소창에 입력하였던 주소는 변하지 않습니다.

- httpd.conf 에 반드시 AllowOverride 항목이 All 로 되어있어야 합니다.

  None 상태일 경우 별도 파일인 .htaccess 에서 작동이 되지 않습니다.

반응형

댓글()

아파치 user, group 을 root 권한으로 설정

리눅스/APACHE|2015. 1. 16. 16:43
반응형

일반적으로 아파치는 User, Group 을 nobody 권한으로 이용하나,

관리자 root 계정으로 가동할 경우 에러메세지를 보이며 실행이 되지 않습니다.

본래 아파치가 그렇게 정의되어있으며, 이를 무시하고 root 권한으로 가동하고자 할 경우 재컴파일이 필요합니다.

 

우선 설정복구가 쉽도록 아파치 설정파일을 백업해놓고

소스폴더로 이동하여 재컴파일 합니다.

 

1. 백업 및 삭제

여러 백업방법이 있으나 간단한 cp 명령을 이용하여 백업합니다.

[root@sysdocu ~]# cd /usr/local

[root@sysdocu local]# cp -arp apache apache.bak.100610

 

백업하였으면 설치되어있던 아파치를 삭제합니다.

[root@sysdocu local]# rm -rf /usr/local/apache

 

 

2. 컴파일

아파치 소스폴더로 이동하여 재컴파일 합니다.

 

[root@sysdocu local]# cd /usr/local/src/httpd-2.2.11

[root@sysdocu httpd-2.2.11]export EXTRA_CFLAGS="-DBIG_SECURITY_HOLE"
[root@sysdocu httpd-2.2.11]# ./configure --prefix=/usr/local/apache --enable-modules=so --enable-mods-shared=all --enable-modules=shared --enable-ssl --enable-rewrite

[root@sysdocu httpd-2.2.11]# make

[root@sysdocu httpd-2.2.11]# make install

 

이제 httpd.conf 에서 User, Group 항목을 root 로 변환 후 아파치 재시작이 가능합니다.

 

반응형

댓글()

아파치 mod_expires 설정 및 활용

리눅스/APACHE|2015. 1. 16. 16:43
반응형

▶mod_expires.c 설치
/usr/local/apache/bin/apxs -aic /usr/local/src/httpd-2.2.14/modules/metadata/mod_expires.c

 

▶httpd.conf 에 내용추가
LoadModule expires_module libexec/mod_expires.so
<IfModule mod_expires.c>
        ExpiresActive On
        ExpiresDefault "access plus 1 month"
        ExpiresByType application/javascript "access plus 1 month"
        ExpiresByType text/css "access plus 1 month"
        ExpiresByType image/jpeg "access plus 1 month"
        ExpiresByType image/gif "access plus 1 month"
        ExpiresByType image/png "access plus 1 month"

        <Directory "/usr/local/apache/htdocs">
                ExpiresActive Off
        </Directory>
</IfModule>

 


▶추가
ExpiresByType application/x-javascript "access plus 1 month"
ExpiresByType text/css "access plus 1 month"

ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/bmp "access plus 1 month"
ExpiresByType image/cgm "access plus 1 month"
ExpiresByType image/tiff "access plus 1 month"

ExpiresByType video/mpeg "access plus 1 month"
ExpiresByType video/quicktime "access plus 1 month"
ExpiresByType video/x-msvideo "access plus 1 month"

ExpiresByType audio/basic "access plus 1 month"
ExpiresByType audio/midi "access plus 1 month"
ExpiresByType audio/mpeg "access plus 1 month"
ExpiresByType audio/x-aiff "access plus 1 month"
ExpiresByType audio/x-mpegurl "access plus 1 month"
ExpiresByType audio/x-pn-realaudio "access plus 1 month"
ExpiresByType audio/x-wav  "access plus 1 month"

ExpiresByType application/x-shockwave-flash  "access plus 1 month"

▶아파치 재시작
/usr/local/apache/bin/apachectl restart

※주의
DSO 방식으로 설치된 아파치만 적용가능

 

 

설정
<VirtualHost *>
ServerName img.xxxxxx.co.kr
DocumentRoot /home/test/www
#########이미지(gif/jpeg) 캐싱 한달로 설정############# 
<Directory "/home/auction/www/img">
ExpiresActive On
ExpiresByType image/jpeg "acces plus 1 month"
ExpiresByType image/gif "acces plus 1 month"
</Directory>
################################################
</VirtualHost>

 

 

작동 확인
lynx  -head http://img.xxxxxx.com/img/204630001160317126.jpg  --> 결과에서 'Cache-Control:' 헤더 부분 확인

Date: Tue, 12 Dec 2006 07:40:21 GMT
Server: Apache
Last-Modified: Sun, 08 Oct 2006 14:18:46 GMT
ETag: "76962b-23516-621f3d80"
Accept-Ranges: bytes
Content-Length: 144662
Cache-Control: max-age=2592000
Expires: Thu, 11 Jan 2007 07:40:21 GMT
Connection: close
Content-Type: image/jpeg

max-age=86400이면 하루이다.

 

[출처] WEB | superman4u (http://blog.naver.com/superman4u?Redirect=Log&logNo=40101316345)
2592000은 30일 

반응형

댓글()

이미지 링크 방지 설정하기

리눅스/APACHE|2015. 1. 16. 16:43
반응형

www.hihome.com 의 계정을 가진 회원들이 계정에 올려진 이미지를 외부에서 링크시키면 
이미지가 제대로 보이지 않는다는 얘기를 듣고서 아파치 설정으로 가능할 것 같아서 
세팅을 해보았습니다.

 

원래 아파치 httpd.conf 세팅

<VirtualHost www.abc.com
   DocumentRoot /home/httpd/htdocs 
   ServerName www.abc.com 
   ErrorLog logs/error_www.abc.com 
   CustomLog logs/access_www.abc.com common 
</VirtualHost>

 

수정된 아파치 httpd.conf 세팅 
<VirtualHost www.abc.com
   DocumentRoot /home/httpd/htdocs 
   ServerName www.abc.com 
   ErrorLog logs/error_www.abc.com 
   CustomLog logs/access_www.abc.com common 
## 수정부분 시작 
   SetEnvIF Referer "http://abc.com" pass

   SetEnvIF Referer "http://www.abc.com" pass 
   <FilesMatch ".(avi|mge?g|exe|jpe?g|mp3|gif|png|zip|asx|asf|wmv|wma|bmp)$">
   Order deny,allow 
   deny from all 
   allow from env=pass 
   ErrorDocument 403 "이미지 링크하지 마세요!" 
   </FilesMatch> 
## 수정부분 끝 
</VirtualHost>

 

간단히 설명하자면 Referer 중 http://www.abc.com 이라는 값에 
pass 라는 환경변수를 설정하였다가 gif, jpg, jpeg, png 이미지를 억세스할때 
pass 환경변수가 있으면 억세스가 되고 없으면 접속거부를 하도록 하는 겁니다. 


반응형

댓글()

Tomcat 관리자 tomcat administration, tomcat manager 설정하기

리눅스/APACHE|2015. 1. 16. 16:42
반응형

Tomcat 서버 설치 및 환경 세팅

  • http://jakarta.apache.org/tomcat/index.html에서 원하는 Tomcat의 버전을 다운받는다.
  • 다운받은 Tomcat을 원하는 디렉토리에 압축을 푼다.
  • CATALINA_HOME을 시스템 환경변수에 설정한다.(굳이 시스템 환경변수에 추가하지 않아도 된다.)
  • CATALINA_HOME/bin의 startup.bat(Windows의 경우), startup.sh(Unix, Linux의 경우)을 실행한다.
  • Tomcat이 정상적으로 시작한다는 메세지를 확인한 후 http://localhost:8080으로 접근하면 고양이 한마리가 나타나면 Tomcat 서버가 정상적으로 시작된 것이다.
  • Tomcat을 설치하고 세팅하는 과정은 생각보다 간단하다.
  • Admin, Manager 애플리케이션 설정하기

    • Tomcat 설치를 완료한 다음 서버를 시작하면 Tomcat 서버에서 제공하는 Admin, Manager 애플리케이션을 사용할 수 있다.
    • http://localhost:8080/admin, http://localhost:8080/manager/html로 접근해본다. Admin과 Manager 애플리케이션이 시작된 것을 확인할 수 있다.
    • Admin과 Manager 기능은 Tomcat 서버를 관리하는 관리자가 필요한 애플리케이션이기 때문에 로그인을 필요로 한다. 로그인을 위하여 필요한 계정 정보를 설정하는 과정은 다음과 같다.

      • CATALINA_HOME/conf/tomcat-users.xml 파일을 연다.
      • Admin 애플리케이션에 접근하기 위해서는 admin role과 admin role을 가지는 계정, Manager 애플리케이션에 접근하기 위해서는 manager role과 manager role을 가지는 계정이 하니씩 필요하다. 물론 같은 계정이 admin과 manager role을 모두 가질 수도 있다. 다음은 admin과 manager role과 계정을 추가한 예이다.
      •     
        
        <?xml version='1.0' encoding='utf-8'?>
        <tomcat-users>
          <role rolename="tomcat"/>
          <role rolename="role1"/>
          <role rolename="manager"/>
          <role rolename="admin"/>
          <user username="tomcat" password="tomcat" roles="tomcat"/>
          <user username="role1" password="tomcat" roles="role1"/>
          <user username="both" password="tomcat" roles="tomcat,role1"/>
          <user username="admin" password="admin" roles="admin,manager"/>
        </tomcat-users>  
        

        위 예의 <role/>태그는 manager와 admin role을 설정하고 있다. 위 예제 소스를 보면 admin과 manager role을 가지는 admin 계정을 추가하고 있다. 비밀번호 또한 admin이다.


반응형

댓글()

tomcat 5.5.9 에 admin 설치 하기

리눅스/APACHE|2015. 1. 16. 16:42
반응형

tomcat 5.5.9 에 admin 설치 하기

http://archive.apache.org/dist/jakarta/tomcat-5/v5.5.9/bin/ 여기에서 파일 다운 받습니다.

 

압축을 풀어서

jakarta-tomcat-5.5.9-adminjakarta-tomcat-5.5.9serverwebappsadmin 폴더를

/usr/local/tomcat/server/webapps/ 에 붙여 넣습니다.

그리고,

 

 

/usr/local/tomcat/conf/server.xml에 추가해줌

추가 위치는 <HOST> </HOST> 사이에 해줌.

<Context path="/manager" debug="0" privileged="true" docBase="/usr/local/tomcat/server/webapps/manager">
</Context>
<Context path="/admin" debug="0" privileged="true" docBase="/usr/local/tomcat/server/webapps/admin">
</Context>

 

 

/usr/local/tomcat/conf/tomcat-users.xml 에 추가

    <user username="admin" password="admin" roles="standard,admin,manager"/>


그런다음 tomcat restart하고 다시 익스플로어 띄워서 접속해봄.


반응형

댓글()

모노(mono) 설치하기 - Installing Mono on CentOS 5

리눅스/APACHE|2015. 1. 16. 16:41
반응형

리눅스에서 asp.net 을 사용할 수 있게 해주는 모듈입니다.

아파치에 탑재하여 사용하는 오픈소스 이며 .net 1 과 .net 2 사용이 가능합니다.

 

--------------------------------------------------

Installing Mono on CentOS 5

 

There are a variety of ways to install Mono. I elected to use CentOS version 5 as the base operating system, and since this is basically RedHat Enterprise Server with some simple re-branding, it seemed that the best way to do this was via the Yum package manager. Well, this sounds great in theory, but it broke. It turns out that binaries created for CentOS 4 are not exactly compatible with CentOS 5.

Who knew?

So, it's back to an installation from source. Fortunately, this is not terribly difficult. Here is the basic system/software I was installing on:

  • CentOS 5
  • Dual Core Pentium IV processor (3 GHz)
  • Apache 2.0.59
  • Mono 1.2.4
  • Apache is installed from source -- I can't help it. I like to know exactly what's installed, and how it's configured; I still don't trust RPMs.

    I elected to install Mono in /opt. The directory didn't exist, so I first created it. I logged in, su-d to root, and created the directory:

    [root@luther]# cd /
    [root@luther]# mkdir opt

    Then I changed to the newly created directory, and downloaded the necessary files. In order to serve .aspx files, we need the mono base, the XSP server, and mod_mono. I got all those files using the trust wget application:

    [root@luther]# cd opt
    [root@luther]# wget http://go-mono.com/sources/mono/mono-1.2.4.tar.bz2
    [root@luther]# wget http://go-mono.com/sources/xsp/xsp-1.2.4.tar.bz2
    [root@luther]# wget http://go-mono.com/sources/mod_mono/mod_mono-1.2.4.tar.bz2

    Now, upack everything:

    [root@luther]# tar jxvmfp *.bz2

    Change to the newly created mono-1.2.4 directory, and configure mono. Notice the parameter I passed the configure program; it tells it to install mono in /opt/mono. I then make, and make install the application.

    [root@luther]# cd mono-1.2.4
    [root@luther]# ./configure --prefix=/opt/mono
    [root@luther]# make ; make install

    Wait a bit, and voila -- you have the mono base installed. Now let's do the same thing for Xsp. Xsp is the web server for mono -- it handles the compilation and delivery of .aspx files. This is pretty simple as well:

    [root@luther]# cd ../xsp-1.2.4
    [root@luther]# ./configure --prefix=/opt/mono
    [root@luther]# make ; make install

    If "configure" or "make" complains about not finding something, try executing this:

    [root@luther]# export PATH=/opt/mono/bin:$PATH

    Then run the above commands again.

    Now, on to mod_mono:

    [root@luther]# cd ../mod_mono-1.2.4
    [root@luther]# ./configure --prefix=/opt/mono --with-mono-prefix=/opt/mono --with-apr-config=/usr/local/apache2/bin/apr-config
    [root@luther]# make ; make install

    When this is done, if you go to /usr/local/apache2/modules (or wherever you told it apache lives) and look at the files there, you should see these: mod_mono.so (a symlink) and mod_mono.so.0.0.0. These are the modules (well, there's only really one -- mod_mono.so is a pointer to mod_mono.so.0.0.0) that apache needs to invoke xsp and deliver .aspx files.

    Now we need to configure apache.

    Open the apache configuration file with your fvourite editor (we'll use vi):

    [root@luther]# vi /usr/local/apache2/conf/httpd.conf

    Go to the bottom of that file, and append this text:

    <IfModule !mod_mono.c>
    LoadModule mono_module /usr/local/apache2/modules/mod_mono.so
    AddType application/x-asp-net .aspx
    AddType application/x-asp-net .asmx
    AddType application/x-asp-net .ashx
    AddType application/x-asp-net .asax
    AddType application/x-asp-net .ascx
    AddType application/x-asp-net .soap
    AddType application/x-asp-net .rem
    AddType application/x-asp-net .axd
    AddType application/x-asp-net .cs
    AddType application/x-asp-net .config
    AddType application/x-asp-net .Config
    AddType application/x-asp-net .dll
    AddType application/x-asp-net .asp
    DirectoryIndex index.aspx
    DirectoryIndex Default.aspx
    DirectoryIndex default.aspx
    </IfModule>

    Now, we'll configure a virtual host to serve up the test suite that ships with mono. In the virtual host section of your file, put in something like this:

    <VirtualHost 198.xxx.xxx.xxx:80>
    DocumentRoot /home/httpd/aspx/html
    ServerName aspx.yoursite.com
    Alias /demo /opt/mono/lib/xsp/test
    MonoApplications "/demo:/opt/mono/lib/xsp/test"
    MonoServerPath /opt/mono/lib/mono/1.0/mod-mono-server.exe
    <Directory /opt/mono/lib/xps/test>
    SetHandler mono
    </Directory>
    </VirtualHost>

    Note that you should specify your actual DocumentRoot and IP address to whatever you are using. This tells Apache that everything served under http://aspx.yoursite.com/demo is actually found in /opt/mono/lib/xsp/test, and handled by mono.

    Restart apache, and go to http://aspx.yoursite.com/demo/index.aspx

    You should see the full mono test suite.

    Cool, eh?

    Note that with this configuration, I can also put aspx files right in the document root for my virtual host, and they will be handled by mono as well. For example, I put this in the root level of the web server and called it test.aspx:

    <html>
    <body>
    <% Response.Write("Hello World!"); %>
    </body>
    </html>

    And it compiled and worked just fine.

     

     

    [출처] SYSCLUB | 곰돌이 ( http://blog.naver.com/koreaotn?Redirect=Log&logNo=10025068291 )

     

     ※ 참고 : mod_mono 다운로드 사이트 : http://ftp.novell.com/pub/mono/sources-stable/


반응형

댓글()

mod_cband 설치 및 사용 방법 (다른것. 설치 에러 포함)

리눅스/APACHE|2015. 1. 16. 16:41
반응형

/usr/local/src/mod-cband-0.9.7.4] ./configure --with-apxs=/usr/local/apache/bin/apxs

make

make install 하면 아래와 같은 에러가 발생한다.

---------------------------------------------------------------------------------------------------------------------
/usr/local/apache/bin/apxs -Wc,-Wall -Wc,-DDST_CLASS=3 -i -a -n cband src/mod_cband.la
/usr/local/apache/build/instdso.sh SH_LIBTOOL='/usr/local/apache/build/libtool' src/mod_cband.la /usr/local/apache/modules
/usr/local/apache/build/libtool --mode=install cp src/mod_cband.la /usr/local/apache/modules/
cp src/.libs/mod_cband.lai /usr/local/apache/modules/mod_cband.la
cp src/.libs/mod_cband.a /usr/local/apache/modules/mod_cband.a
ranlib /usr/local/apache/modules/mod_cband.a
chmod 644 /usr/local/apache/modules/mod_cband.a
PATH="$PATH:/sbin" ldconfig -n /usr/local/apache/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/local/apache/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Warning!  dlname not found in /usr/local/apache/modules/mod_cband.la.
Assuming installing a .so rather than a libtool archive.
chmod 755 /usr/local/apache/modules/mod_cband.so
chmod: cannot access `/usr/local/apache/modules/mod_cband.so': 그런 파일이나 디렉토리가 없음
apxs:Error: Command failed with rc=65536
.
make: *** [install] 오류 1
---------------------------------------------------------------------------------------------------------------------

보통 so 파일이 에러 나는건 
/usr/local/apache/build/instdso.sh SH_LIBTOOL='/usr/local/apache/build/libtool'  여기의 libtool 파일의 호환성문제이다. 

cp /usr/bin/libtool /usr/local/apache/build/ 을 해주고 make install 하면 해결 될 것이다.  


설정하기 

mod_throttle의 throttle-status와 throttle-me의 역활을 할수 있게 설정한다. 

httpd.conf 마지막줄에 아래의 구문을 추가하도록 한다. 

--------------------------------- httpd.conf ---------------------------------- 

<Location /cband-status> 
SetHandler cband-status 
</Location> 
<Location /cband-status-me> 
SetHandler cband-status-me 
</Location> 

-------------------------------------------------------------------------------- 

설정을 완료하고 Apache를 재시작시키고 http://서버주소/cband-status로 접속해보면 
throttle-status와는 좀 다른 살짝 복잡하고 알록달록한 페이지를 만날수 있다. 

VirtualHost 트래픽제한하기 

대부분의 유저가 mod_throttle 및 mod_bandwidth를 사용하는 이유가 VirtualHost별 트래픽제한을 목적으로 두고 있을것이다. 
mod_cband라고 설정방법이 크게 다르진 않다. 

예제1) VirtualHost별 트래픽제한하기 
<VirtualHost *> 
. 
. 
CBandLimit 500Mi 
CBandPeriod 1D

CBandExceededURL http://test.pe.kr/xxx.html

# test.com에 대해 1일에 500Mbyte 의 트레픽을 허용하며 그 트레픽을 초과하면 http://test.pe.kr/xxx.html을 출력합니다.

</VirtualHost> 

예제2) 여러개의 주소를 사용하는 사용자의 트래픽 묶어서 제한하기 
<대부분 웹호스팅을 하거나 할 경우 한 사용자가 여러개의 도메인을 사용하는 경우가 많고, 그에 따라 여러개의 <VirtualHost> 를 가지게 되는 경우가 빈번합니다. 그럴 땐 어떻게 하느냐?

<CBandUser user>
   CBandUserLimit 300Mi
   CBandUserPeriod 1D
</CBandUser>
<VirtualHost *:80>
   ServerName oper.or.kr
   DocumentRoot /usr/local/www/data
   CBandUser user
</VirtualHost>
<VirtualHost *:80>
   ServerName ik.oper.or.kr
   DocumentRoot /usr/local/www/data
   CBandUser user
</VirtualHost>

일종의 클래스 개념입니다. user 라는 클래서는 1일에 300Mbyte 의 전송량을 할당받고, oper.or.kr 과 ik.oper.or.kr 도메인이 user 클래스의 영향을 받는다는 구문입니다. CBandExceededURL 를 지정하지 않았기 때문에 트레픽을 초과하면 503 에러를 출력합니다.

  이 외에도 VirtualHost 별로 대역폭 설정 및 접속 IP 별로 대역폭 설정 등을 할 수 있지만, 그 부분은 다루지 않겠습니다. (왜냐? 역시 초보라..)
  설정을 다 하셨으면 apache 를 재시작해 주시고요. 이제 http://Domain/cband-status 와 http://Domain/cband-status-me 로 접속해 확인합니다. 물론 위에서 설정한 Domain 으로 접속해야겠죠?

1) 단위
  * 전송속도 단위
     o kbps, Mbps, Gbps - bits per second:1024, 1024*1024 , 1024*1024*1024 bps
     o kb/s, Mb/s, Gb/s - bytes persecond:  1024, 1024*1024, 1024*1024*1024 b/s
     o 기본 : kbps

  * 트래픽 쿼터 단위
     o K, M, G - bytes: 1000, 1000*1000,1000*1000*1000 bytes
     o Ki, Mi, Gi - bytes: 1024, 1024*1024,1024*1024*1024 bytes
     o 기본 : K

  * 시간(기간) 단위 
     o S, M, H, D, W - 초, 분, 시간, 일, 주
     o 기본 : S

 

2) 지시자들
  (1) 이름 : CBandDefaultExceededURL
     설명 : 제한을 초과했을때보여줄 URL  (지정하지 않으면, 503 에러 페이지)
     문맥 : Serverconfig
      문법 :CBandDefaultExceededURL URL

 

  (2) 이름 : CBandDefaultExceededCode
     설명 : 제한을 초과했을시 보여줄 에러코드
     문맥 : Server config
     문법 :CBandDefaultExceededCode HTTP_CODE
     예제 :CBandDefaultExceededCode 509 

 

  (3) 이름 : CBandScoreFlushPeriod
     설명 : scoreboard 파일에기록할 요청수, mod_cband 의 성능에 영향을 준다.
     기본값 : 1
     문맥 : Server config
     문법 :CBandScoreFlushPeriod 요청수
     예제 :CBandScoreFlushPeriod 100  ( 매 100번의 요청에 한번씩 scoreboard 파일에 기록)

 

  (4) 이름 : CBandSpeed
     설명 : 가상호스트 도메인의 최대 속도,요청수, 접속수  설정
     문맥 :<Virtualhost>
     문법 : CBandSpeed kbpsrps max_conn
             kbps - 초당 최대 전송속도
             rps - 초당 최대 요청수
             max_conn - 최대 동시 접속수 
     예제 : CBandSpeed 102410 30
             최대 1024kbps전송속도로 제한, 초당 10개의 요청 처리, 동시 접속을 30개로 제한.

 

  (5) 이름 : CBandRemoteSpeed
     설명 : 접속자(IP)의 최대속도,요청수, 접속수 제한 (CBandSpeed와 비슷하지만, 접속자당 설정)
     문맥 :<Virtualhost>
     문법 : CBandRemoteSpeedkbps rps max_conn
             kbps - 초당 최대 전송속도
             rps - 초당최대 요청수
             max_conn - 최대 동시 접속수
     예제 : CBandRemoteSpeed20kb/s 3 3
             접속자(ip)에대해 최대 20kb/s , 초당 3개의 요청, 동시 접속 3개로 제한.

 

  (6) 이름 : CBandClassRemoteSpeed
     설명 : 정의한 class(ip 범위)에대해 최대속도, 요청수, 접속수 제한
     문맥 :<Virtualhost>
     문법 :CBandClassRemoteSpeed class_name kbps rps
             class_name - 이미 정의한 클래스 이름 (IP범위)
             kbps - 초당 최대 전송속도
             rps - 초당 최대 요청수
             max_conn - 최대 동시 접속수
      예제 : <CBandClassgooglebot_class>
               CBandClassDst 66.249.64/24
               CBandClassDst 66.249.65/24
               CBandClassDst 66.249.79/24
             </CBandClass>
                   CBandClassRemoteSpeedgooglebot_class 20kb/s 2 3
                   위에서 정의한클래스(googlebot_class)의 요청에는 20kb/s 의 전송속도, 초당 3개의 요청, 동시 접속 3개로 제한.

 

  (7) 이름 : CBandRandomPulse
     설명 : 속도 제한을 위해서 임의의파형을 생성한 다음 처리하는 mod_cband의 처리 방법이다.
              부하가 많을때는 자동 Off된다.
     문맥 : Global
     문법 : CBandRandomPulseOn/Off

 

  (8) 이름 : CBandLimit
     설명 : 제한할 전송량을 설정한다.(기간은 CBandPeriod 에서 설정)
     문맥 :<Virtualhost>
     문법 : CBandLimit limit
             limit - 전송량, 사용단위: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi),Gi (gibi)
     예제 : CBandLimit 10M - 전송양을 10M(10*1000*1000bytes)로 제한한다.
             CBandLimit 10Mi - 전송양을 10M(10*1024*1024bytes)로 제한한다.

 

  (9) 이름 : CBandClassLimit
     설명 : 정의한 class(ip범위)에대해 제한할 전송량 설정.
     문맥 :<Virtualhost>
     문법 : CBandClassLimitclass_name limit
             class_name - 이미 정의한 클래스 이름(ip범위)
             limit - 전송량, 사용단위: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi),Gi (gibi)

 

  (10) 이름 : CBandExceededURL
     설명 : 제한을 초과했을시 보여줄URL, 지정하지 않으면 503 에러 발생 (가상호스트에서) 
     문맥 :<Virtualhost>
     문법 : CBandExceededURLURL

 

  (11) 이름 : CBandExceededSpeed
     설명 : 전송양을 초과했을시 , 전송속도제한 설정.
     문맥 :<Virtualhost>
     문법 :CBandExceededSpeed kbps rps max_conn
             kbps - 초당 최대 전송속도
             rps - 초당 최대 요청수
             max_conn - 최대 동시 접속수

 

  (12) 이름 : CBandScoreboard
     설명 : 가상호스트의 scoreboard파일 지정. (성능향상을 위해 필요)
     문맥 :<Virtualhost>
     문법 : CBandScoreboardpath 
             (path는 아파치(www)권한으로 쓰기가능해야 함)

 

  (13) 이름 : CBandPeriod
     설명 : 용량제한기간(이 기간이 지나면,측정되었던 용량은 지워진다.)
     문맥 :<Virtualhost>
     문법 : CBandPeriod period
             period - 사용단위: S (초), M (분), H (시간), D (일), W (주)
     예제 : CBandPeriod1W  (1주일)
             CBandPeriod 14D  (14일)
             CBandPeriod 60M  (60분)

 

  (14) 이름 : CBandPeriodSlice
     설명 : 기간이 길때는 나눌 기간을명시한다. 
     기본값 : slice_len = limit
     문맥 :<Virtualhost>
     문법 : CBandPeriodSliceslice_length
     예제 : CBandLimit 100G
             CBandPeriod 4W
             CBandPeriodSlice 1W
              4주는 1주일 단위로 나뉜다(4W/1W = 4). 용량은 100G/4=25G 
              1주에 25G, 2주째 50G 이렇게 나눠 처리 된다.

 

  (15) 이름 : <CBandUser>
     설명 : 새로운 cband 가상 사용자설정
     문맥 : Server config
     문법 : <CBandUseruser_name>

 

  (16) 이름 : CBandUserSpeed
     설명 : cband 가상 사용자의 속도,요청수, 동시 접속수 제한 
     문맥 : <CBandUser>
     문법 : CBandUserSpeedkbps rps max_conn
             kbps - 초당 최대 전송속도
             rps - 초당 최대 요청수
             max_conn - 최대 동시 접속수
     예제 : CBandUserSpeed100kb/s 10 5

 

  (17) 이름 : CBandUserLimit
     설명 : cband 가상 사용자의 저송용량 제한.
     문맥 : <CBandUser>
     문법 : CBandUserLimitlimit
             limit - 사용용량, 사용단위: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi), Gi (gibi)
     예제 : CBandUserLimit 10M
             CBandUserLimit 10Mi

 

  (18) 이름 : CBandUserClassLimit
     설명 : cband 가상 사용자의 정의한class(ip범위)에 대해 제한할 전송량 설정
     문맥 : <CBandUser>
     문법 :CBandUserClassLimit class_name limit
             class_name - 지정한 class(IP범위)이름
             limit -사용용량, 사용단위: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi),Gi (gibi)

 

  (19) 이름 : CBandUserExceededURL
     설명 : cband 가상 사용자의,제한을 초과했을시 보여줄 URL,
              지정하지 않으면 503 에러 발생 ( 가상호스트에서 ) 
     문맥 : <CBandUser>
     문법 :CBandUserExceededURL URL

 

  (20) 이름 : CBandUserExceededSpeed
     설명 : cband 가상 사용자의,전송양을 초과했을시 , 전송속도 제한 설정.
     문맥 : <CBandUser>
     문법 :CBandUserExceededSpeed kbps rps max_conn
             kbps - 초당 최대 전송속도
             rps - 초당 최대 요청수
             max_conn - 최대 동시 접속수

 

  (21) 이름 : CBandUserScoreboard
     설명 : cband 가상 사용자의,scoreboard 파일 지정.
     문맥 : <CBandUser>
     문법 :CBandUserScoreboard path
             (path는 아파치(www)권한으로 쓰기가능해야 함)

 

  (22) 이름 : CBandUserPeriod
     설명 : cband 가상 사용자의,용량제한기간(이 기간이 지나면, 측정되었던 용량은 지워진다.)
     문맥 : <CBandUser>
     문법 : CBandUserPeriodperiod
             period - 사용단위: S (초), M (분), H (시간), D (일), W (주)
     예제 : CBandUserPeriod 1W
             CBandUserPeriod 14D
             CBandUserPeriod 60M

 

  (23) 이름 : CBandUserPeriodSlice
     설명 : cband 가상 사용자의,기간을 나눌 기간 명시
     기본값 : slice_len = limit
     문맥 : <CBandUser>
     문법 :CBandUserPeriodSlice slice_length
     예제 : CBandUserLimit100G
             CBandUserPeriod 4W
             CBandUserPeriodSlice 1W
              4주는 1주일 단위로 나뉜다(4W/1W = 4). 용량은 100G/4=25G 
              1주에 25G, 2주째 50G 이렇게 나눠 처리 된다.

 

[출처] 어제 보다 나은 오늘을 , 오늘보다 나은 내일을 위해서

             http://reboot.co.kr/entry/Modcband-%EC%84%A4%EC%B9%98%EA%B8%B0

 

 

 

웹페이지 암호 걸기

 

Location 항목에 아래와 같이 입력 후

 

<Location /cband-status>
    SetHandler cband-status
    AuthName "트래픽 관리 페이지"
    AuthType Basic
    AuthUserFile /usr/local/apache/conf/cband_status/.htpasswd
    require valid-user
</Location>

<Location /cband-status-me>
    SetHandler cband-status-me
    Order deny,allow
    Deny from all
    Allow from all
</Location>

 

암호 설정을 이용하여 id, passwd 를 설정 합니다.

반응형

댓글()

mod_cband 설치 및 사용 방법

리눅스/APACHE|2015. 1. 16. 16:40
반응형

0. 내가 원한는 것?
  예전에 apache 1은 mod_throttle으로 가상호스트별 트래픽 측정 및 제한이 가능했습니다.
이 트래픽 제한 기능은 호스팅을 하기 위해서는 필수입니다. 어떤 도메인에서 많이 사용하는지
아는 것은 아주 중요한 일이기 때문입니다. 하지만, 
apache2를 쓰면 이놈을 포기할 수 밖에 없었습니다. 검색하다 .. cband를 찾았습니다.
mod_throttle과 기능및 구조 거의 흡사하며, mod_bandwidth의 기능까지포함했고,
최근에 개발되어 계속 성능 향상이 되어 가고 있었습니다.
보다 좋은건, ?xml 이라고 붙여주면, 데이터를 xml형태로 얻을 수 있어,
호스팅 하기에 정말 좋은 모듈입니다.


[주의] cband는 apache 2 모듈이다. apache 1.3.XX용이아니며 1.3.XX는 mod_throttle을 사용하세요!!

[주요기능]
   * Apache2용 가볍운 트래픽제한 모듈
   * 사용자별 대역폭제한 기능
   * 가상호스트별 대역폭 제한 기능
   * 목적지별 대역폭 제한 기능
   * 제한기능:
         o 모든사용자 대역폭 제한
         o 다운로드 속제 제한
         o 초당요청수 제한
         o 아이피대역별 제한
   * Support for virtualhosts
   * Support for defined users
   * 제한결과 웹을 통한 확인 (/cband-status)
   * 각 사용자별 제한 결과 확인(/cband-status-me)



1. 설치방법
  cd /usr/local
  wget http://cband.linux.pl/download/mod-cband-0.9.7.5.tgz 
  tar xvfpzmod-cband-0.9.7.5.tgz 
  cd mod-cband-0.9.7.5
  ./configure --with-apxs=/usr/local/apache/bin/apxs
  ## 옵션설명 
  ## --with-apxs=/usr/local/apache/bin/apxs : 아파치 apxs경로를 지정합니다.
  make
  make install


2. 설치확인
  - httpd.conf 파일에
    LoadModulecband_module       modules/mod_cband.so 
  줄이 추가된것을 볼 수 있습니다.
  - 아파치/modules 디렉토리에
    mod_cband.so 
   파일이 추가 된 것을 볼수 있습니다.


3. 기본 설정

====================================
  <Location /cband-status>
    SetHandler cband-status
    Order deny,allow
    Deny from all
    Allow from all

  </Location> 

  <Location /cband-status-me> 
   SetHandler cband-status-me
  </Location> 

<VirtualHost *>
  ServerNamegnux.co.kr    
  Document /home/gnux/www
   CBandLimit 300Mi
  CBandPeriod 1D
  CBandExceededURL http://manager.gnux.co.kr/traffic_exceeded.html
</VirtualHost>
======================================
위 설정파일은 gnux.co.kr 도메인에 
하루에 300M(300*1024*1024byte)의트래픽을 제공하는 설정입니다.
bit로 따지면, 2.4Gbit/일 트래픽을 제공하는 것입니다.
만약 하루에 300M를 초과했다면, "http://manager.gnux.co.kr/traffic_exceeded.html"
페이지가 뜨며, 지정하지 않았다면, 503 에러 페이지가 뜨게됩니다.
만약!. 제한을 하지 않고 관찰만 하려 한다면, CBandPeriod 부분만 남기고 삭제합니다.




4. 상황별 설정
1) 자료실 속도 제한
==============================
<VirtualHost *>
  ServerNamefile.gnux.co.kr    
  Document /home/gnux/file
 CBandSpeed 1024 10 30
 CBandRemoteSpeed 20kb/s 3 30
</VirtualHost>
==============================
위 설정은  file.gnux.co.kr 도메인에 대해서
속도를 1024kbps 로 제한하며, 초당 10번의 연결,
동시접속자를 30으로 제한하는 예제입니다.



2) 사용자 일트래픽 제공 및 초과시 연결수 제한.
==============================
<VirtualHost *>
  ServerNamedoly.gnux.co.kr    
  Document /home/gnux/doly
 CBandLimit 100Mi
 CBandExceededSpeed 128 5 15
 CBandPeriod 1D
</VirtualHost>
==============================
위 설정은 doly.gnux.co.kr도메인에 대해
하루에 100Mbyte의 트레픽을 제공하며,
100M를 초가했다면, 
속도를 128bps로 제한, 초당 5번의 연결,
동시접속자를 15로 제한하는 예제입니다.



3) 한 사용자에 여러 도메인이 있다면?
==============================
<CBandUserhost_user1>
  CBandUserLimit 100Mi
  CBandUserPeriod 1D
</CBandUser>
<VirtualHost *>
  ServerNameaaa.co.kr    
  Document/home/host_user1/aaa
  CBandUser host_user1
</VirtualHost>
<VirtualHost *>
  ServerNamebbb.co.kr    
  Document/home/host_user1/bbb
  CBandUser host_user1
</VirtualHost>
==============================
위 설정은 host_user1이라는 가상 사용자를 지정한다음.
그 사용자는 하루에 100Mbyte를 사용할수 있게합니다.
그런다음, aaa.co.kr, bbb.co.kr 모두 host_user1의 
트래픽을 사용하게 설정하였습니다.



4) IP대역에 따라 속도를 제한하고 싶다면?
==============================================
<CBandClassclass_1>
  CBandClassDst 192.168.0.0/24
</CBandClass>
<CBandClassclass_2>
  CBandClassDst 222.97.189.0/24
</CBandClass>

<VirtualHost *>
  ServerNameintranet.gnux.co.kr    
  Document/home/gnux/intranet
 CBandClassRemoteSpeed class_1 50Mbps 10 30
 CBandClassRemoteSpeed class_2 300kbps 10 30
</VirtualHost>
==============================================
위 설정은, 내부아이피 192.168.0.XXX 에서,
50Mbps의 대역폭과, 초당 10번의 요청, 동시접속자 30을 설정하며,
다른 ip대역 222.97.189.XXX에서는 
300kpbs, 초당 10번의 요청, 동시접속자 30을 설정합니다.


5. 사용량 확인.
  http://도메인/cband-status
  http://도메인/cband-status-me
status

** xml 형태로 데이터를 얻고 싶다면?
 http://도메인/cband-status?xml
 http://도메인/cband-status-me?xml
xml



6. 지시자 및 단위설명 (필요시 찾아보세요!!)
  1) 단위.
   * 전송속도 단위
         o kbps, Mbps, Gbps - bits per second:1024, 1024*1024 , 1024*1024*1024 bps
         o kb/s, Mb/s, Gb/s - bytes persecond:  1024, 1024*1024, 1024*1024*1024 b/s
         o 기본 : kbps 

   * 트래픽 쿼터 단위
         o K, M, G - bytes: 1000, 1000*1000,1000*1000*1000 bytes
         o Ki, Mi, Gi - bytes: 1024, 1024*1024,1024*1024*1024 bytes
         o 기본 : K

   * 시간(기간) 단위 
         o S, M, H, D, W - 초, 분, 시간, 일, 주
         o 기본 : S 

  2) 지시자들
    (1) 이름 : CBandDefaultExceededURL
         설명 : 제한을 초과했을때보여줄 URL  (지정하지 않으면, 503 에러 페이지)
           문맥 : Serverconfig
         문법 :CBandDefaultExceededURL URL

    (2)이름 : CBandDefaultExceededCode
        설명 : 제한을 초과했을시 보여줄 에러코드
        문맥 : Server config
        문법 :CBandDefaultExceededCode HTTP_CODE
        예제 :CBandDefaultExceededCode 509  


    (3)이름 : CBandScoreFlushPeriod
        설명 : scoreboard 파일에기록할 요청수, mod_cband 의 성능에 영향을 준다.
        기본값 : 1
        문맥 : Server config
        문법 :CBandScoreFlushPeriod 요청수
        예제 :CBandScoreFlushPeriod 100  ( 매 100번의 요청에 한번씩 scoreboard 파일에 기록)

    (4)이름 : CBandSpeed
        설명 : 가상호스트 도메인의 최대 속도,요청수, 접속수  설정
        문맥 :<Virtualhost>
        문법 : CBandSpeed kbpsrps max_conn
              kbps - 초당 최대 전송속도
              rps - 초당 최대 요청수
              max_conn - 최대 동시 접속수 
        예제 : CBandSpeed 102410 30
               최대 1024kbps전송속도로 제한, 초당 10개의 요청 처리, 동시 접속을 30개로 제한.

    (5)이름 : CBandRemoteSpeed
        설명 : 접속자(IP)의 최대속도,요청수, 접속수 제한 (CBandSpeed와 비슷하지만, 접속자당 설정)
        문맥 :<Virtualhost>
        문법 : CBandRemoteSpeedkbps rps max_conn
                kbps - 초당 최대 전송속도
                rps - 초당최대 요청수
                max_conn - 최대 동시 접속수
        예제 : CBandRemoteSpeed20kb/s 3 3
                접속자(ip)에대해 최대 20kb/s , 초당 3개의 요청, 동시 접속 3개로 제한.

    (6)이름 : CBandClassRemoteSpeed
        설명 : 정의한 class(ip 범위)에대해 최대속도, 요청수, 접속수 제한
        문맥 :<Virtualhost>
        문법 :CBandClassRemoteSpeed class_name kbps rps
                class_name - 이미 정의한 클래스 이름 (IP범위)
                kbps - 초당 최대 전송속도
                rps - 초당 최대 요청수
                max_conn - 최대 동시 접속수
        예제 : <CBandClassgooglebot_class>
                  CBandClassDst 66.249.64/24
                  CBandClassDst 66.249.65/24
                  CBandClassDst 66.249.79/24
                </CBandClass>
                      CBandClassRemoteSpeedgooglebot_class 20kb/s 2 3
                      위에서 정의한클래스(googlebot_class)의 요청에는 20kb/s 의 전송속도, 
                     초당 3개의 요청, 동시 접속 3개로 제한.

    (7)이름 : CBandRandomPulse
        설명 : 속도 제한을 위해서 임의의파형을 생성한 다음 처리하는 mod_cband의 처리 방법이다.
                  부하가 많을때는 자동 Off된다.
        문맥 : Global
        문법 : CBandRandomPulseOn/Off

    (8)이름 : CBandLimit
        설명 : 제한할 전송량을 설정한다.(기간은 CBandPeriod 에서 설정)
        문맥 :<Virtualhost>
        문법 : CBandLimit limit
                limit - 전송량, 사용단위: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi),Gi (gibi)
        예제 : CBandLimit 10M
                  전송양을 10M(10*1000*1000bytes)로 제한한다.
                CBandLimit 10Mi
                  전송양을 10M(10*1024*1024bytes)로 제한한다.

    (9)이름 : CBandClassLimit
        설명 : 정의한 class(ip범위)에대해 제한할 전송량 설정.
        문맥 :<Virtualhost>
        문법 : CBandClassLimitclass_name limit
                class_name - 이미 정의한 클래스 이름(ip범위)
                limit - 전송량, 사용단위: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi),Gi (gibi)

  (10)이름 : CBandExceededURL
        설명 : 제한을 초과했을시 보여줄URL, 지정하지 않으면 503 에러 발생 ( 가상호스트에서 ) 
        문맥 :<Virtualhost>
        문법 : CBandExceededURLURL

  (11)이름 : CBandExceededSpeed
        설명 : 전송양을 초과했을시 , 전송속도제한 설정.
        문맥 :<Virtualhost>
        문법 :CBandExceededSpeed kbps rps max_conn
                kbps - 초당 최대 전송속도
                rps - 초당 최대 요청수
                max_conn - 최대 동시 접속수

   (12)이름 : CBandScoreboard
        설명 : 가상호스트의 scoreboard파일 지정. (성능향상을 위해 필요)
        문맥 :<Virtualhost>
        문법 : CBandScoreboardpath 
                (path는 아파치(nobody또는 apache)권한으로 쓰기가능해야 함)

   (13)이름 : CBandPeriod
        설명 : 용량제한기간(이 기간이 지나면,측정되었던 용량은 지워진다.)
        문맥 :<Virtualhost>
        문법 : CBandPeriod period
                period - 사용단위: S (초), M (분), H (시간), D (일), W (주)
        예제 : CBandPeriod1W  (1주일)
                CBandPeriod 14D  (14일)
                CBandPeriod 60M  (60분)

  (14)이름 : CBandPeriodSlice
        설명 : 기간이 길때는 나눌 기간을명시한다. 
        기본값 : slice_len = limit
        문맥 :<Virtualhost>
        문법 : CBandPeriodSliceslice_length
        예제 : CBandLimit 100G
                CBandPeriod 4W
                CBandPeriodSlice 1W
                 4주는 1주일 단위로 나뉜다(4W/1W = 4). 용량은 100G/4=25G 
                 1주에 25G, 2주째 50G 이렇게 나눠 처리 된다.

  (15)이름 : <CBandUser>
        설명 : 새로운 cband 가상 사용자설정
        문맥 : Server config
        문법 : <CBandUseruser_name>

  (16)이름 : CBandUserSpeed
        설명 : cband 가상 사용자의 속도,요청수, 동시 접속수 제한 
        문맥 : <CBandUser>
        문법 : CBandUserSpeedkbps rps max_conn
                kbps - 초당 최대 전송속도
                rps - 초당 최대 요청수
                max_conn - 최대 동시 접속수
        예제 : CBandUserSpeed100kb/s 10 5


  (17)이름 : CBandUserLimit
        설명 : cband 가상 사용자의 저송용량 제한.
        문맥 : <CBandUser>
        문법 : CBandUserLimitlimit
                limit - 사용용량, 사용단위: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi),Gi (gibi)
        예제 : CBandUserLimit 10M
                CBandUserLimit 10Mi

  (18)이름 : CBandUserClassLimit
        설명 : cband 가상 사용자의 정의한class(ip범위)에 대해 제한할 전송량 설정
        문맥 : <CBandUser>
        문법 :CBandUserClassLimit class_name limit
                class_name - 지정한 class(IP범위)이름
                limit -사용용량, 사용단위: K (kilo), M (mega), G (giga), Ki (kibi), Mi (mebi),Gi (gibi)

  (19)이름 : CBandUserExceededURL
        설명 : cband 가상 사용자의,제한을 초과했을시 보여줄 URL,
                  지정하지 않으면 503 에러 발생 ( 가상호스트에서 ) 
        문맥 : <CBandUser>
        문법 :CBandUserExceededURL URL

  (20)이름 : CBandUserExceededSpeed
        설명 : cband 가상 사용자의,전송양을 초과했을시 , 전송속도 제한 설정.
        문맥 : <CBandUser>
        문법 :CBandUserExceededSpeed kbps rps max_conn
                kbps - 초당 최대 전송속도
                rps - 초당 최대 요청수
                max_conn - 최대 동시 접속수

  (21)이름 : CBandUserScoreboard
        설명 : cband 가상 사용자의,scoreboard 파일 지정.
        문맥 : <CBandUser>
        문법 :CBandUserScoreboard path
                (path는 아파치(nobody또는 apache)권한으로 쓰기가능해야 함)

  (22) 이름 : CBandUserPeriod
        설명 : cband 가상 사용자의,용량제한기간(이 기간이 지나면, 측정되었던 용량은 지워진다.)
        문맥 : <CBandUser>
        문법 : CBandUserPeriodperiod
                period - 사용단위: S (초), M (분), H (시간), D (일), W (주)
        예제 : CBandUserPeriod 1W
                CBandUserPeriod 14D
                CBandUserPeriod 60M

  (23)이름 : CBandUserPeriodSlice
        설명 : cband 가상 사용자의,기간을 나눌 기간 명시
        기본값 : slice_len = limit
        문맥 : <CBandUser>
        문법 :CBandUserPeriodSlice slice_length
        예제 : CBandUserLimit100G
                CBandUserPeriod 4W
                CBandUserPeriodSlice 1W
                 4주는 1주일 단위로 나뉜다(4W/1W = 4). 용량은 100G/4=25G 
                 1주에 25G, 2주째 50G 이렇게 나눠 처리 된다.


7. 마치며..
이것으로 현재 최신버전의 mod_cband 설치 및 운영, 상세 지시자 설명 하는 강좌를 마치겠습니다.
처음 이 모듈을 발견했을때 너무 너무 기뻣고, 바로 적용해 테스트 하였습니다.
특히 xml로 데이터를 추출할 수 있어 가공함에 있어 아주 아주 편리했습니다.
국내에는 아직 mod_cband에 과한 강좌가 없어 많은 사람들에게 
도움을 주기 위해서 이렇게 강좌를 작성합니다.
  본 강좌에 대해서 오타 및 문제가 있다면, doly골뱅이superuser.co.kr으로 메일 
한통 바랍니다.

2006년 6월 ... 모기들이 태어나는 계절에... 도리...


** 본 문서의 저작권은GPL이지만, 본 사이트(www.superuser.co.kr) 이외의 사이트에서 
배포는 허용하지 않습니다.

 

[출처] mod_cband 사용법|작성자 옹이

 

 

웹페이지 암호 걸기

 

Location 항목에 아래와 같이 입력 후

 

<Location /cband-status>
    SetHandler cband-status
    AuthName "트래픽 관리 페이지"
    AuthType Basic
    AuthUserFile /usr/local/apache/conf/cband_status/.htpasswd
    require valid-user
</Location>

<Location /cband-status-me>
    SetHandler cband-status-me
    Order deny,allow
    Deny from all
    Allow from all
</Location>

 

암호 설정을 이용하여 id, passwd 를 설정 합니다.



mod-cband-0.9.7.5.tgz


반응형

댓글()

404 에러 페이지 변경

리눅스/APACHE|2015. 1. 16. 16:39
반응형

웹서버페 페이지가없을경우,

 

페이지를 찾을 수 없습니다. 또는 HTTP 404 ERROR 라는 페이지를 보여줍니다.

 

이러한 에러페이지를 바꿀 수 있습니다.

 

1. virtualhost 에 등록된 DocumentRoot 를 참고하여 홈디렉토리로 이동합니다.

 

2. DocumentRoot 디렉토리에서 .htaccess 파일을 생성 후 404 에러 페이지를 연결시켜줍니다.

    # vi .htaccess

ErrorDocument 404 http://sysdocu.tistory.com/404.php

 

※ 물론 위와같이 설정했을 경우, 홈디렉토리(DocumentRoot)에 404.php 가 있어야 합니다.

 

※ 기타 다른 도메인(없는 서브도메인) 의 경우, virtualhost 를 추가하여 DocumentRoot 를 특정 폴더로, ServerName 을 IP로 등록하여

     특정 폴더에 .htaccess 파일을 생성합니다.

    > 서브도메인이 없는경우, 기본 IP로 연결되므로. (네임서버에서 서브도메인 * 표시가 있어야 함)

 

반응형

댓글()