← 가이드

Apache 보안 조치 가이드

Apache httpd 에서 TLS 프로토콜 제한, 보안 헤더, HTTPS 리다이렉트를 적용하는 단계별 절차

0단계 — 서버 확인 (모든 조치 공통)

① 서버 접속 — SSH 접속, sudo 권한 필요.

② 웹서버 타입·버전 확인

ps -ef | grep -E 'httpd|apache2' | grep -v grep
httpd -v 2>/dev/null || apache2 -v          # 버전 (Debian 계열은 apache2)
httpd -V 2>/dev/null || apache2ctl -V        # HTTPD_ROOT·SERVER_CONFIG_FILE 경로 출력

③ 설정 파일 위치 찾기 — ②의 -V 출력에서:

-D HTTPD_ROOT="/etc/httpd"
-D SERVER_CONFIG_FILE="conf/httpd.conf"

SSL 설정은 보통 conf.d/ssl.conf(RHEL) 또는 sites-enabled/*(Debian). 확인:

grep -rn "SSLProtocol\|SSLCertificateFile" /etc/httpd/ /etc/apache2/ 2>/dev/null

④ 인증서 경로 — ③의 SSLCertificateFile / SSLCertificateKeyFile 값.


TLS 1.0/1.1 비활성 + TLS 1.3 활성

SSL 설정 파일(VirtualHost 443 또는 전역)에서:

# OpenSSL 1.1.1+ 환경
SSLProtocol -all +TLSv1.2 +TLSv1.3

# TLSv1.3 을 모르는 구버전이면
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1

두 표기 모두 mod_ssl 공식 문법이다 (-all +... = 전체 비활성 후 선택 활성, all -... = 전체 활성 후 제외).

보안 헤더

mod_headers 활성 확인 후 (Debian: a2enmod headers):

Header always set Strict-Transport-Security "max-age=31536000; includeSubDomains"
Header always set X-Content-Type-Options "nosniff"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set Referrer-Policy "strict-origin-when-cross-origin"
Header always set Content-Security-Policy "default-src 'self'"

HTTP → HTTPS 리다이렉트

80 포트 VirtualHost 에:

<VirtualHost *:80>
    ServerName 도메인
    Redirect permanent / https://도메인/
</VirtualHost>

인증서 교체 (약한 키·서명)

Apache·IIS 인증서 교체 절차 참조. 2.4.8 미만은 SSLCertificateChainFile 분리 지정에 주의.

신규 도메인 인증서 설치

발급·파일 준비는 발급 공통 가이드 먼저.

① 파일 배치 — /etc/httpd/ssl/ 등, 개인키 chmod 600.

② VirtualHost 추가:

<VirtualHost *:443>
    ServerName 새도메인
    SSLEngine on
    # 2.4.8+ : fullchain 한 파일
    SSLCertificateFile      /etc/httpd/ssl/fullchain.pem
    SSLCertificateKeyFile   /etc/httpd/ssl/privkey.pem
    # 2.4.8 미만은 분리:
    # SSLCertificateFile      /etc/httpd/ssl/cert.pem
    # SSLCertificateChainFile /etc/httpd/ssl/chain.pem
</VirtualHost>
<VirtualHost *:80>
    ServerName 새도메인
    Redirect permanent / https://새도메인/
</VirtualHost>

③ 확인 — 진단 툴 또는 openssl. 버전별 체인 지정 실수는 교체 절차 글 참조.

최종 확인

진단 툴로 재검사 (결과 캐시 최대 10분).

참조 문서 (공식)