Apache HTTP 서버 레벨에서 IP 주소를 차단하는 방법

Apache HTTP Server 수준에서 IP 주소를 차단하는 방법을 알아봅니다. Apache 웹 서버의 /etc/conf.d 폴더에서 차단할 IP가 있는 .conf 파일을 만듭니다.

설명 description

환경

Adobe Experience Manager

문제/증상

사이트에서 서비스 거부 공격, 스팸 또는 해킹이 발생하고 있습니다. Apache HTTP 서버(AEM Dispatcher) 레벨에서 IP 주소를 차단하는 방법

해결 방법 resolution

MOD 보안과 같은 대부분의 WAF(Web Application Firewall)는 IP 주소의 차단 목록을 수행할 수 있습니다. 그러나 Apache HTTP 서버를 실행하고 있고 IP를 즉시 차단하려는 경우, 다음 단계를 수행하십시오(AEM as a Cloud Service에는 적용되지 않습니다.):

  1. 이름이 인 파일 만들기 block-offending-ips.conf 서버에서

  2. 편집기에서 파일을 열고 차단하려는 URL에 대한 모든 잘못된 IP의 액세스를 차단하는 Location 지시문을 추가합니다. 아래 파일의 내용에는 두 가지 옵션이 있습니다.
    A. 요청이 프록시 설정(CDN, 로드 밸런서 등을 통해)되고 원격 사용자의 IP가 X-Forwarded-For와 같은 헤더에만 있는 경우 이 구성을 사용할 수 있습니다. remoteip_module이 구성된 경우에는 이 구성이 적용되지 않습니다.

    code language-none
    LocationMatch "/.*"
        Order Allow,Deny
        Allow from all
        SetEnvif X-Forwarded-For "10\.42\.137\.123" DenyAccess
        SetEnvif X-Forwarded-For "122\.6\.218\.101" DenyAccess
        #Repeat the "SetEnvlf X-Forwarded-For ..." for each IP you want to block
        Deny from env=DenyAccess
        /LocationMatch
    

    B. 또는 원격 사용자가 Apache에 직접 액세스하거나 remoteip_module을 사용하는 경우( 참조) [ 1] 아래) 를 입력하여 Apache 내에서 추출 및 설정한 다음 mod_authz_core 필요 직접 기능(Apache 2.4).

    code language-none
    LocationMatch "/.*"
        RequireAll
        Require all granted
        Require not ip 10.42.137.123
        Require not ip 122.6.218.101
        #Repeat the "Require not ip ..." for each IP you want to block
        /RequireAll
        /LocationMatch
    

    [ 1] remoteip_module

    code language-none
    # Extract true client IP from header added by load balancer/CDN
        IfModule remotetip module
        # valid for ELB or ELB+CloudFront
        RemoteIPHeader X-Forwarded-For
        IfModule
    
  3. Apache 웹 서버의 /etc/conf.d 폴더에 block-offending-ips.conf 파일을 놓습니다.

  4. Apache HTTP 서버를 다시 시작합니다.

recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f