본문 바로가기

WEB/Apache,OHS

[Apache] Apache2.4 - 보안 취약점 & 성능 개선 설정 변경

#. 참고 글

https://m.blog.naver.com/PostView.naver?isHttpsRedirect=true&blogId=leeyoon0607&logNo=70048567922

 


 

 

Method 제한 설정

https://hyuunchul.tistory.com/296

 


 

server-status 설정

특정 IP 에서만 접근 가능하도록 제어한다.

https://hyuunchul.tistory.com/297

 


 

ServerTokens 설정

httpd.conf 파일을 수정한다.

httpd-default.conf 를 사용하도록 Include 한다.

httpd-default.conf 파일을 수정한다.

서버 상세 정보가 노출되지 않도록 ProductOnly 로 변경한다.

ServerTokens ProductOnly

 


 

메모리 cache 관련 옵션

httpd.conf 에서 아래 내용 수정

 - EnableMMAP 옵션 off로 설정

 - EnableSendfile 옵션도 off로 설정

 

DocumentRoot의 <Directory> 태그 내에 아래 옵션 추가

    Header always set Pragma "no-cache"
    Header always set Expires "Thu, 1 Jan 1970 00:00:00 GMT"
    Header always set Cache-Control "max-age=0, no-store, no-cache, must-revalidate"
    Header unset ETag
    FileEtag None

 


 

MPM 값 튜닝 (EVENT MPM)

httpd-mpm.conf 를 사용하도록 Include 한다.

 

httpd-mpm.conf 설정

 

default 세팅

<IfModule mpm_event_module>
    StartServers             3
    MinSpareThreads         75
    MaxSpareThreads        250
    ThreadsPerChild         25
    MaxRequestWorkers      400
    MaxConnectionsPerChild   0
</IfModule>

 

동시접속자 수 2048명 세팅

<IfModule mpm_event_module>
    StartServers             32
    ServerLimit              32
    MinSpareThreads        512
    MaxSpareThreads        1024
    ThreadsPerChild          64
    MaxRequestWorkers      2048
    MaxConnectionsPerChild    0
    AsyncRequestWorkerFactor  1
</IfModule>

 

동시접속자 수 4096명 세팅

<IfModule mpm_event_module>
    StartServers             64
    ServerLimit              64
    MinSpareThreads        1024
    MaxSpareThreads        3072
    ThreadsPerChild          64
    MaxRequestWorkers      4096
    MaxConnectionsPerChild    0
    AsyncRequestWorkerFactor  1
</IfModule>

 


 

MPM 값 튜닝 (WinNT MPM)

동시접속자 수 2048명 세팅

<IfModule mpm_winnt_module>
    ThreadsPerChild        2048
    ThreadLimit             2048
    MaxConnectionsPerChild   0
</IfModule>

 


 

Cookie 관련 보안 옵션

httpd.conf 파일에 추가

Header edit Set-Cookie ^(.*)$ $1;HttpOnly;Secure;SameSite=None;

 


 

X-Content-Type 옵션

httpd.conf 파일에 추가

Header always set X-Content-Type-Options nosniff

 


 

X-XSS-Protection 옵션

httpd.conf 파일에 추가

Header always set X-XSS-Protection "1; mode=block"

 


 

Content-Security-Policy 옵션

httpd.conf 파일에 추가

보안 정책에 위배되는 request 발생 시, 웹 브라우저의 개발자 도구 console 상에 에러 로그가 출력된다.

Header always set Content-Security-Policy "default-src 'self' 'unsafe-inline' 'unsafe-eval'"

 

Content-Security-Policy-Report-Only 옵션

httpd.conf 파일에 추가

Content-Security-Policy 옵션에 설정하는 방식과 완전히 동일하다.

보안 정책 위배 시 console 상에 동일한 내용의 에러 로그를 기록하나, 맨 앞에 [Report Only] 태그가 붙게 된다.

실제로 보안 정책이 서버 상에 적용되지 않고, 경고만 하는 옵션이다.

Header always set Content-Security-Policy-Report-Only "default-src 'self' 'unsafe-inline' 'unsafe-eval'"

 


 

SSL 프로토콜 관련 옵션

httpd-ssl.conf 파일에 설정한다.

TLS1.2 버전과 TLS1.3 버전만 허용하도록 한다.

#   SSL Protocol support:
#   List the protocol versions which clients are allowed to connect with.
#   Disable SSLv3 by default (cf. RFC 7525 3.1.1).  TLSv1 (1.0) should be
#   disabled as quickly as practical.  By the end of 2016, only the TLSv1.2
#   protocol or later should remain in use.
#SSLProtocol all -SSLv3
#SSLProxyProtocol all -SSLv3
SSLProtocol -all +TLSv1.2 +TLSv1.3
SSLProxyProtocol -all +TLSv1.2 +TLSv1.3

 


 

#. mod_jk 사용하는 경우

 

mod_jk - workers.properties 수정

connection_pool_minsize, connection_pool_size 값을 

MPM Event 에서 설정한 ThreadsPerChild 값과 동일하게 세팅해 주어야 한다.

둘 다 동일한 값으로 세팅한다.

worker.template.connection_pool_minsize=64
worker.template.connection_pool_size=64