'apache'에 해당되는 글 15건

  1. 2009.03.31 apache mod_expires 설정
  2. 2009.01.13 apache trace method
  3. 2009.01.09 apache DirectoryIndex 란?
  4. 2009.01.05 apache tuning tip..
  5. 2008.07.30 apache+tomcat+jdk 설치 및 연동 1

apache mod_expires 설정

ITWeb/서버관리 2009. 3. 31. 17:38


FileETag MTime Size

<IfModule mod_expires.c>
 ExpiresActive On

 ExpiresDefault "access plus 1 days"
 ExpiresByType image/gif "access plus 1 days"
 ExpiresByType image/png "access plus 1 days"
 ExpiresByType image/jpeg "access plus 1 days"
 ExpiresByType text/css "access plus 1 days"
 ExpiresByType application/javascript "access plus 1 days"
 ExpiresByType application/x-shockwave-flash "access plus 1 days"
</IfModule>

이미지 서버의 apache 설정 중 mod_expires 랑 FileETag 설정 이다.
기냥.. 1 days 로 설정을 해봤다..
각각의 퍼포먼스에 대해서는 구글링 하면 많이 나오니 참고들 하세요.

:

apache trace method

ITWeb/서버관리 2009. 1. 13. 15:38

TraceEnable Off

이 옵션은 cross-site tracing 공격에 노출 되는 문제와 더불어 basic 인증의 패스워드를 가로챌 수 있는 취약점이 있습니다.

trace method 가 꼭 필요한 것이 아니면 apache conf 설정 시 off 로 설정 하고 사용하세요.

또 다른 방법으로는 mod_rewrite 로 방지가 가능 합니다.

RewriteEngine On
RewriteCond %{REQUEST_METHOD} ^TRACE
RewriteRule .* - [F]

이렇게 하시면.. 403 forbidden 메시지가 떨어 집니다..
꼭 테스트는 해보세요.. ^^*

실제 어떻게 사용 하냐구요..

telnet localhost 80
TRACE / HTTP/1.0
와 같이 사용 하지요..

google 에 trace method 로 검색 하시면.. 좋은 정보 많이 나옵니다.. :)

:

apache DirectoryIndex 란?

ITWeb/서버관리 2009. 1. 9. 15:42
출처 : http://httpd.apache.org/docs/2.0/mod/mod_dir.html

DirectoryIndex 지시어

설명: 클라이언트가 디렉토리를 요청할때 찾아볼 자원 목록
문법: DirectoryIndex local-url [local-url] ...
기본값: DirectoryIndex index.html
사용장소: 주서버설정, 가상호스트, directory, .htaccess
Override 옵션: Indexes
상태: Base
모듈: mod_dir

DirectoryIndex 지시어는 클라이언트가 디렉토리명 끝에 /를 붙여서 디렉토리의 index를 요청할때 찾아볼 자원 목록을 지정한다. Local-url은 요청한 디렉토리에 상대적인 문서의 (%로 인코딩된) URL이다. 보통은 디렉토리에 있는 파일명이다. 여러 URL을 지정할 수 있고, 이 경우 서버는 첫번째로 찾은 파일을 보낸다. 자원을 찾을 수 없고 Indexes 옵션을 설정하였다면 서버는 직접 디렉토리 목록을 만든다.

예제

DirectoryIndex index.html

이 경우 http://myserver/docs/를 요청할때 http://myserver/docs/index.html이 있으면 이를 보내고, 없다면 디렉토리 목록을 보낸다.

문서가 반드시 디렉토리에 상대적일 필요는 없다.

DirectoryIndex index.html index.txt /cgi-bin/index.pl

이 경우 디렉토리에 index.html이나 index.txt가 없으면 CGI 스크립트 /cgi-bin/index.pl을 실행한다.


----------> 여기서 부터는 나의 해석.. ㅋ
그럼 이넘이랑..
RewirteRule ^/$   /index.html [R]
RewirteRule ^/$   /index.html [L]
이거랑 뭐가 다를까?
그리고 둘다 넣었을 경우 어떻게 응답을 할까?

우선 apache 에서는 RewriteRule 이 먼저 적용 된다.
이넘 들 실행 후에 암것도 없거나 그러면.. DirectoryIndex 를 찾는다..
어떤 경우에.. 파일 지정을 하지 않았거나 / 로 끝났을 경우에..

[R] 은.. access 로그를 보면 알겠지만.. request 두번 (302 한번, 200 한번)
[L] 은 access 로그에 처음 요청 URL 한번

그럼 이 [R], [L] 이건 또 뭐야??
아파치 문서에는 이렇게 되어 있다..

출처 : http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html

'redirect|R [=code]' (force redirect)
Prefix Substitution with http://thishost[:thisport]/ (which makes the new URL a URI) to force a external redirection. If no code is given, a HTTP response of 302 (MOVED TEMPORARILY) will be returned. If you want to use other response codes in the range 300-400, simply specify the appropriate number or use one of the following symbolic names: temp (default), permanent, seeother. Use this for rules to canonicalize the URL and return it to the client - to translate ``/~'' into ``/u/'', or to always append a slash to /u/user, etc.
Note: When you use this flag, make sure that the substitution field is a valid URL! Otherwise, you will be redirecting to an invalid location. Remember that this flag on its own will only prepend http://thishost[:thisport]/ to the URL, and rewriting will continue. Usually, you will want to stop rewriting at this point, and redirect immediately. To stop rewriting, you should add the 'L' flag.

  • 'last|L' (last rule)
    Stop the rewriting process here and don't apply any more rewrite rules. This corresponds to the Perl last command or the break command in C. Use this flag to prevent the currently rewritten URL from being rewritten further by following rules. For example, use it to rewrite the root-path URL ('/') to a real one, e.g., '/e/www/'.
  • 그렇군.. 뭔 말인지 알지?? ^^;; ㅋ
    뭐 말 그대로 인고.. redirect 근데 이넘은.. URL 도 같이 변경이 되고..
    last 는 기냥.. 여기서 그만.. 더 이상 하위 rule 은 실행을 하지 않는 다는 의미 이지요..
    그럼 이넘은.. 왜 R 처럼 URL 이 바뀌지는 않는 걸까? 설명에 있잖아..

    ㅎㅎ 그럼.. 이건 여기서 이제 그만.. ㅎㅎ

    :

    apache tuning tip..

    ITWeb/서버관리 2009. 1. 5. 13:37

    기냥 access_log 쪽 tuning 을 좀 할까 하다.. 어서 본거 몇자 적어 본다.. (나중에 또 까먹지 말도록..)
    http://httpd.apache.org/docs/2.0/mod/mod_log_config.html
    http://httpd.apache.org/docs/2.0/ko/mod/mod_setenvif.html

    AllowOverride 설정은 None 으로 하는걸 추천 합니다.
    왜 인지는 문서를 보세요. ㅋ
    .htaccess 파일을 매 request 마다 오픈 하게 되면 당연히 퍼포먼스가 안좋겠죠..
    그래서 None 으로 설정을 하게 됩니다.

    이와 더불어 Options FollowSymLinks 도 사용하세요.
    apache 가 symlink 인지 확인 하기 위해서 system call 을 하게 되는 부하를 줄일수 있다고 하내요.

    KeepAlive Off
    dynamic content 를 요구 하는 web server 설정에는 off 로 하시구요.
    static content 를 요구 하는 이미지 server 설정에는 on 으로 하시면 좋습니다.
    특성에 맞춰서 잘 사용하시면 당근 좋겠죠.. ;;

    Allow from ip range 표현은..
    Allow from 196.128 또는 196.128.* : 196.128 로 시작하는 ip 만
    Allow from 196.128.0.0 - 196.128.0.255 : 해당 범위 까지만
    Allow from 196.128.0.0/196.168.0.255

    Allow from 196.128.0.0 196.128.0.1 : space 로 구분 지어서 설정한 ip 만

    Allow from 196.128.0.0/24 == 196.128.0.0/255.255.255.0 : netmask 와 연동

    암튼.. reference url 은.. http://www.apache.org

    아래는 어서 봤는데 원본 링크가 생각이 안난다는..ㅡㅜ; I'm sorry.
    all
    All hosts are allowed access.

    A (partial) domain name
    All hosts whose names match or end in this string are allowed access.

    A full IP address
    The first one to three bytes of an IP address are allowed access, for subnet restriction.

    A network/netmask pair
    Network a.b.c.d and netmask w.x.y.z are allowed access, to give finer-grained subnet control. For instance, 10.1.0.0/255.255.0.0.

    A network CIDR specification
    The netmask consists of nnn high-order 1-bits. For instance, 10.1.0.0/16 is the same as 10.1.0.0/255.255.0.0.

    :

    apache+tomcat+jdk 설치 및 연동

    ITWeb/서버관리 2008. 7. 30. 12:38

    Download
    * http://java.sun.com/javase/downloads/index_jdk5.jsp
    JDK 5.0 Update 16 다운로드 받음
    http://java.sun.com/j2se/1.5.0/install-linux.html

    * http://httpd.apache.org/download.cgi
    httpd-2.2.9.tar.gz

    * http://tomcat.apache.org/
    apache-tomcat-6.0.16.tar.gz

    * http://tomcat.apache.org/connectors-doc/
    tomcat-connectors-1.2.26-src.tar.gz
    mod_jk-1.2.26-httpd-2.2.6.so

    Installation
    * JDK 설치
    download 경로 및 설치 시작 위치 : /home/app/download/
    설치 경로 : /home/app/java/jdk
    설치하기
    파일권한변경
    $ /home/app/download/]chmod 744 jdk-1_5_0_16-linux-i586.bin
    $ /home/app/download/]./jdk-1_5_0_16-linux-i586.bin
    약관같은 내용 스킵(q 누르고 빠져 나옴)
    yes 입력후 설치 시작
    $ /home/app/download/]cd jdk1.5.xxx
    $ /home/app/download/]mv -f * /home/app/java/jdk
    $ /home/app/download/]cd ..
    $ /home/app/download/]rm -rf ./jdk1.5.xxx
    JAVA_HOME 과 path 설정
    .cshrc 기준
    setenv JAVA_HOME "/home/app/java/jdk"
    set path=( $path $JAVA_HOME/bin )

    기 설치된 java 삭제 (rpm 설치)
    설치 pkg 확인 (root 로 실행)
    삭제 및 java version 확인
    $ /home/app/download/]rpm -qif /usr/lib/jvm/jre-1.4.2-gcj/bin/java
    $ /home/app/download/]rpm -e java-1.4.2-gcj-compat
    $ /home/app/download/]java -version

    * tomcat 설치
    $ /home/app/download/] tar -xvzf apache-tomcat-6.0.16.tar.gz
    $ /home/app/download/]mv -f ./apache-tomcat-6.0.16 ../tomcat

    .cshrc 기준
    setenv CATALINA_HOME "/home/app/tomcat"
    set path=( $path $CATALINA_HOME/bin )

    tomcat 설치 테스트
    $ /home/app/tomcat/bin]startup.sh

    http://localhost:8080/

    * apache 설치
    # jsp 를 사용하기 땜시 기본 설치 합니다.
    $ /home/app/download/httpd-2.2.9]./configure --prefix=/home1/irteam/naver/apache-2.2.9 --enable-so --with-mpm=worker
    $ /home/app/download/httpd-2.2.9]make clean
    $ /home/app/download/httpd-2.2.9]make
    $ /home/app/download/httpd-2.2.9]make install

    * apache tomcat connector
    apache 와 tomcat 을 연동하기 위해서 설치
    ref. ttp://tomcat.apache.org/connectors-doc/webserver_howto/apache.html
    ref. http://www.akadia.com/download/soug/tomcat/html/tomcat_apache.html

      • source build 하기
        tar -xvzf tomcat-connectors-1.2.26-src.tar.gz
        cd tomcat-connectors-1.2.26-src/native
        ./buildconf.sh
        ./configure --with-apxs=/home/app/apache-2.2.9/bin/apxs ## <-- apxs 가 설치된 위치 지정
        make
        make install
        cd apache-2.0 ## <-- 들어가 보시면 mod_jk.so 가 생성되어 있습니다. apache 설치 경로의 ~/modules/ 아래 보시면 mod_jk.so 가 복사되어 있지 않으면 복사해서 넣기
      • httpd.conf 수정하기
        # tomcat.conf 설정은 LoadModule 설정 최상단에 위치
        # apache module load 순서와 연관
        include conf/tomcat.conf
        include extra/httpd-vhost.conf
      • tomcat.conf 수정하기
        # JkMount 와 같은 option 들은 virtualhost 설정에서 잡아주고 
        # 아래는 공통 설정
        LoadModule jk_module modules/mod_jk.so
        
        JkWorkersFile           conf/workers.properties
        JkShmFile               /home/app/logs/apache/mod_jk.shm
        JkLogFile               /home1/app/logs/apache/mod_jk.log
        JkLogLevel              debug
        JkLogStampFormat        "[%a %b %d %H:%M:%S %Y] "
        JkRequestLogFormat  "%w %V %T"
      • workers.properties 수정하기
        workers.tomcat_home=/home/app/tomcat
        workers.java_home=/home/app/java/jdk
        
        ps=/
        worker.list=tebs ## <-- tebs 는 property 또는 서비스 명
        
        worker.tebs.port=8009
        worker.tebs.host=localhost
        worker.tebs.type=ajp13
        worker.tebs.lbfactor=1
      • extra/httpd-vhost.conf 수정하기
        NameVirtualHost *
        
        #
        # VirtualHost example:
        # Almost any Apache directive may go into a VirtualHost container.
        # The first VirtualHost section is used for all requests that do not
        # match a ServerName or ServerAlias in any <VirtualHost> block.
        #
        <VirtualHost *>
            ServerName localhost
            ServerAlias localhost
            ServerAdmin admin@localhost
            DocumentRoot "/home/app/docs/tebs/web"
        
            ErrorLog "/home/app/logs/apache/error"
            CustomLog "/home/app/logs/apache/access" common
        
            JkMount             /*.jsp  tebs # 또는 /* tebs
        
        # htdocs 위치는 아래와 같음.
            <Directory "/home/app/docs/tebs/web">
                AllowOverride None
                Order deny,allow
                Allow from all
            </Directory>
        # 접근 금지
            <Directory "/home/app/docs/tebs/web/WEB-INF">
                AllowOverride None
                Order deny,allow
                Deny from all
                Allow from none
            </Directory>
        # 접근 금지
            <Directory "/home/app/docs/tebs/web/META-INF">
                AllowOverride None
                Order deny,allow
                Deny from all
                Allow from none
            </Directory>
        </VirtualHost>
      • server.xml 수정
        # 위치는 tomcat 설치 위치의 /home/app/tomcat/conf/server.xml
        # 기본 tomcat context root 변경을 위해서 아래와 같이 apache htdocs 설정한 경로로 변경
        <Host name="localhost"  appBase="/home/app/docs/tebs/web"
                    unpackWARs="true" autoDeploy="true"
                    xmlValidation="false" xmlNamespaceAware="false">
                <Context path="" docBase="." debug="0" reloadable="true"></Context>
        </Host>
      • jsp 파일 테스트

        아래 apache 와 tomcat 의 실행 순서 매우 중요
        tomcat daemon 이 먼저 떠 있어야 mod_jk 가 apache 모듈로 load 될때 정상적으로 connect 할 수 있음
        아파치설치경로/bin/apachectl stop
        톰켓설치경로/bin/shutdown.sh
        톰켓설치경로/bin/startup.sh
        아파치설치경로/bin/apachectl start
        # htdocs 로 이동
        cd /home/app/tomcat/webapps/ROOT // 또는 /home/app/tomcat/webapps서비스명 또는 프로젝트명/
        vi index.jsp
        # 브라우저에서 접속 테스트




     






     

    :