Linux/보안장비 운용

웹서버 로그 분석 툴 goaccess 설치하기

GGkeeper 2022. 3. 8. 16:08

실습> 웹서버 로그 분석 툴 goaccess 설치하기

좀 더 최신버전을 사용하기 위해서는 소스를 직접 다운로드 받아서 시스템에 설치한다.
여기서는 yum으로 설치하기로 한다.

1. 네트워크 정보
# nmtui
Vmware Adapter: VMnet8
IPv4 설정       <수동>                  
주소 192.168.108.101/24
게이트웨이 192.168.108.2
DNS 서버 168.126.63.1
[X] 자동으로 연결 

2. 패키지 설치
CentOS 7 에서 아래처럼 epel-release 패키지를 설치하고 goaccess 패키지를 설치한다.
# yum -y install epel-release
# yum -y install php httpd goaccess

3. 설정파일 수정
설정파일을 열어서 아래 3개의 라인의 주석을 해제한다.
# vi /etc/goaccess/goaccess.conf
time-format %H:%M:%S
date-format %d/%b/%Y
log-format %h %^[%d:%t %^] "%r" %s %b

4. goaccess 실행
아파치 웹서버가 0byte 이면 에러가 발생되므로 반드시 로그 파일에 로그가 기록되어 있어야 한다.
# goaccess /var/log/httpd/access_log --log-format=COMBIND

goaccess를 실행하면 아래처럼 화면이 나온다.
여기서 서버로 접속하면 로그가 기록된 것을 분석해서 화면에 정보를 출력한다.

단축키 : 
? : 도움말
Up/Down : 이전, 다음 정보를 출력한다.
q : 종료


  Total Requests  9 Unique Visitors  1  Requested Files 7 Referrers  6
  Valid Requests  9 Init. Proc. Time 0s Static Files    1 Log Size   1.87 KiB
  Failed Requests 0 Excl. IP Hits    0  Not Found       1 Tx. Amount 46.22 KiB
  Log Source      /var/log/httpd/access_log

 > 1 - Unique visitors per day - Including spiders                             Total: 1/1

 Hits      h% Vis.      v% Tx. Amount Data
 ---- ------- ---- ------- ---------- ----
    9 100.00%    1 100.00%  46.22 KiB 13/ 9월/2021  |||||||||||||||||||||||||||||||||||||||


   2 - Requested Files (URLs)                                                  Total: 7/7

 Hits      h% Vis.      v% Tx. Amount Mtd Proto    Data
 [?] Help [Enter] Exp. Panel  6 - Mon Sep 13 16:05:06 2021            [q]uit GoAccess 1.3

5. 정적 HTML 생성
/var/www/html/report.html 로 파일을 생성한다.
# goaccess /var/log/httpd/access_log --log-format=COMBINED -a -o /var/www/html/report.html

--help 옵션을 이용해서 다양한 옵션을 확인할 수 있다.
# goaccess --help

GoAccess - 1.3

웹 브라우저로 접속해서 확인한다.
http://192.168.108.101/report.html

6. 실시간 분석
--real-time-html 을 사용해서 실시간 분석을 활용한다.
--real-time-html                - Enable real-time HTML output.

# goaccess /var/log/httpd/access_log --log-format=COMBINED \
-a -o /var/www/html/report.html --real-time-html

아래로 접속해서 Dashboard를 확인한다.
http://192.168.108.101/report.html

# goaccess /var/log/httpd/access_log --log-format=COMBINED \
-a -o /var/www/html/report.html --real-time-html
WebSocket server ready to accept new client connections
Accepted: 13 192.168.108.1
Active: 1

index2.html 파일을 생성해서 접근하고 report.html로 시각화 프로그램에서 확인한다.
# cd /var/www/html
# vi index2.html
index2.html 입니다.
http://192.168.108.101/index2.html

http://192.168.108.101/report.html

'Linux > 보안장비 운용' 카테고리의 다른 글

아파치 웹서버 데몬이 안뜨는 이유  (0) 2022.03.08
아파치 인증 설정하기  (0) 2022.03.08
logger 사용하기  (0) 2022.03.04
logrotate 실행하기  (0) 2022.03.04
로그 관리 프로그램 logrotate  (0) 2022.03.04