Linux/보안장비 운용

HTTP 환경변수 로그 남기기

GGkeeper 2022. 3. 8. 16:10

실습> HTTP 환경변수 로그 남기기

1. 로그 포맷 변경
%{Foobar}i : Foobar의 내용 - 서버에 요청을 할 때의 헤더에 있는 내용
# vi /etc/httpd/conf/httpd.conf
<IfModule log_config_module>
    :
    :(생략)
    LogFormat "%t \"%r\" \"%{Host}i\" " mylog  
    CustomLog "logs/access_log" mylog
</IfModule>

2. 웹서버 재시작
# httpd -t
# systemctl reload httpd

3. 로그 모니터링
# tail -f /var/log/httpd/access_log

4. 웹서버 접속
브라우저에서 접속한다.
http://192.168.108.101/

5. 로그 확인
# tail -f /var/log/httpd/access_log
[07/Mar/2022:21:16:15 +0900] "GET / HTTP/1.1" "192.168.108.101"