apache httpd.conf

agnusdei·2024년 7월 27일
# 서버의 기본 설정
ServerRoot "/etc/httpd"  # Apache 서버의 설치 디렉토리

# 리스닝 포트 설정
Listen 80  # 서버가 요청을 수신할 포트 번호 (기본값은 80, HTTP 기본 포트)

# 사용자 및 그룹 설정
User apache  # Apache 서버가 실행될 사용자 계정
Group apache  # Apache 서버가 실행될 그룹 계정

# 서버 이름 설정
ServerName www.example.com:80  # 서버의 호스트 이름 및 포트 번호

# 서버 토큰 설정 -> 기출
ServerTokens Prod  # 서버의 응답 헤더에 최소한의 정보만 표시 (Prod: 제품명만 표시) 

# 서버 서명 설정 -> 기출
ServerSignature Off  # 서버의 오류 문서에 서명(버전 정보) 표시 비활성화

# 문서 루트 설정 -> 기출
DocumentRoot "/var/www/html"  # 웹 문서가 위치하는 디렉토리

<Directory "/var/www/html">
    Options Indexes FollowSymLinks  # 디렉토리에서 허용할 옵션들 (파일 인덱싱 및 심볼릭 링크 따라가기 허용) -> 기출
    AllowOverride None  # .htaccess 파일을 통한 설정 덮어쓰기를 허용하지 않음
    Require all granted  # 모든 접근을 허용
</Directory>

# 로깅 설정
ErrorLog "logs/error_log"  # 서버 오류 로그 파일 위치 -> 기출
LogLevel warn  # 로그의 상세 수준 (warn: 경고 및 그 이상 수준의 로그 기록)

<IfModule log_config_module>
    LogFormat "%h %l %u %t \"%r\" %>s %b" common  # 공통 로그 형식 지정
    CustomLog "logs/access_log" common  # 접근 로그 파일 위치 및 형식 지정
</IfModule>

# MIME 타입 설정
TypesConfig /etc/mime.types  # MIME 타입 정의 파일 위치
AddType application/x-gzip .gz .tgz  # 특정 파일 확장자에 대한 MIME 타입 설정

# 모듈 설정
LoadModule mime_module modules/mod_mime.so  # MIME 타입 모듈 로드
LoadModule rewrite_module modules/mod_rewrite.so  # URL 재작성 모듈 로드

# 가상 호스트 설정
<VirtualHost *:80>
    ServerAdmin webmaster@example.com  # 서버 관리자 이메일 주소 -> 기출
    DocumentRoot "/var/www/example"  # 가상 호스트의 문서 루트
    ServerName example.com  # 가상 호스트의 서버 이름
    ErrorLog "logs/example.com-error_log"  # 가상 호스트의 오류 로그 파일
    CustomLog "logs/example.com-access_log" common  # 가상 호스트의 접근 로그 파일
</VirtualHost>

# 보안 설정
<Directory />
    Options FollowSymLinks  # 심볼릭 링크 따라가기를 허용
    AllowOverride None  # .htaccess 파일을 통한 설정 덮어쓰기를 허용하지 않음
    Require all denied  # 기본적으로 모든 접근을 차단
</Directory>

<Directory "/usr/share">
    AllowOverride None  # .htaccess 파일을 통한 설정 덮어쓰기를 허용하지 않음
    Require all granted  # 모든 접근을 허용
</Directory>

# 디렉토리 인덱스 설정
DirectoryIndex index.html index.php  # 디렉토리 접근 시 기본으로 제공할 파일 목록 -> 기출

# KeepAlive 설정
KeepAlive On  # 연결을 지속해서 사용할지 여부 (On: 지속 연결 허용) -> 기출
MaxKeepAliveRequests 100  # 지속 연결에서 허용할 최대 요청 수 -> 기출
KeepAliveTimeout 15  # 지속 연결의 타임아웃 시간 (초 단위)

# 추가적인 보안 및 성능 설정
FileETag None  # 파일 변경을 감지하기 위한 ETag 헤더 사용 안함
ServerSignature Off  # 서버의 오류 문서에 서명(버전 정보) 표시 비활성화 -> 기출

# Timeout 설정
Timeout 300  # 클라이언트와 서버 간의 요청 처리 타임아웃 시간 (초 단위) -> 기출

# MaxClients 설정 (Apache 2.4 이후는 MaxRequestWorkers로 변경) -> 기출
<IfModule mpm_prefork_module>
    MaxRequestWorkers 256  # 동시 연결을 허용할 최대 클라이언트 수
</IfModule>

<IfModule mpm_worker_module>
    ServerLimit 16
    StartServers 2
    MaxRequestWorkers 400  # 동시 연결을 허용할 최대 클라이언트 수
    MinSpareThreads 25
    MaxSpareThreads 75
    ThreadsPerChild 25
    MaxConnectionsPerChild 0
</IfModule>

<IfModule mpm_event_module>
    ServerLimit 16
    StartServers 2
    MaxRequestWorkers 400  # 동시 연결을 허용할 최대 클라이언트 수
    MinSpareThreads 25
    MaxSpareThreads 75
    ThreadsPerChild 25
    MaxConnectionsPerChild 0
</IfModule>
profile
DevSecOps, Pentest, Cloud(OpenStack), Develop, Data Engineering, AI-Agent

0개의 댓글