전체 글 402

[GoAccess] GoAccess X-Forwarded-For 웹 로그 파일 분석 방법 (apache web log analyzer, apache web log file analyzer, x-forwarded analyzer)

GoAccess X-Forwarded-For 웹 로그 파일 분석 방법 X-Forwarded-For 웹 로그 파일의 경우 아래와 같이 IP가 두개로 출력될 수 있기 때문에 GoAccess에서 LogFormat을 맞춰줄 필요가 있습니다. 10.10.10.10, 20.20.20.20 - - [15/May/2020:10:51:14 +0900] "GET / HTTP/1.1" 403 4897 "-" "curl/7.29.0" LogForamt을 맞춰주는 방법은 비교적 굉장히 간단 합니다. 기존에 사용하던 LogFormat이 --log-format='%h %^[%d:%t %^] "%r" %s %b "%R" "%u" %^' 이거였다면, 가장 앞단의 %h를 %h, 으로 변경만 해주시면 X-Forwarded 에서 IP가 2..

[GoAccess] 웹 로그 분석 툴 GoAccess 설치 및 사용 방법 (goaccess install, web log analyzer, web log file analyzer)

웹 로그 분석 툴 GoAccess 설치 및 사용 방법 GoAccess는 웹 로그 파일을 기반으로 분석해서 CLI 환경이나 HTML형태로 보고서를 출력해주는 오픈소스 입니다. yum으로 간단하게 설치할 수 있습니다. yum -y install goaccess 로그 파일을 기반으로 분석하기에 사용 환경에 따라 goaccess 실행 시 logformat을 웹로그와 동일하게 맞춰 주어야할 수 있습니다. 터미널에서 실행 커맨드와 UI는 아래와 같습니다. goaccess access_log --log-format='%h %^[%d:%t %^] "%r" %s %b "%R" "%u" %^' --date-format=%d/%b/%Y --time-format=%T 만약 HTML으로 보고서를 출력받고 싶다면 아래와 같이 커..

[ELK Stack] ELK Apache 로그 수집을 위한 filebeat 설치

ELK 로그 수집을 위한 filebeat 설치 ELK에서 로그를 수집하기 위해 filebeat을 에이전트 노드에 설치해야 합니다. * ELK 서버에 filebaet을 설치하지 않고 ELK서버가 로그를 수집하기 위한 대상 서버들에게 설치합니다. wget https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-6.6.2-x86_64.rpm rpm -vi filebeat-6.6.2-x86_64.rpm systemctl start filebeat systemctl enable filebeat filebeat 로그 수집 설정 방법-1 위의 커맨드를 입력하여 설치 이후 filebeat modules list 를 입력하면 활성화된 모듈과, 비활성화된 모듈을 확..

[CentOS7] 리눅스 logrotate 에러 "error: skipping "/var/log/" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group shou..

리눅스 logrotate 에러 "error: skipping "/var/log/" because parent directory has insecure permissions (It's world writable or writable by group which is not "root") Set "su" directive in config file to tell logrotate which user/group should be used for rotation." 해당 에러는 권한 설정 문제로 발생 합니다. /etc/logrotate.d/ 디렉토리에 생성한 logrotate 파일의 내용에 su root root 를 추가해주면 에러를 해결할 수 있습니다. /var/log/ { su root root daily m..

[ModSecurity 2.9] 아파치 modsecurity2 소스 설치 (apache modsecurity2 install)

아파치 modsecurity2 소스 설치 (apache modsecurity2 install) 아래와 같이 의존성 및 컴파일을 위한 패키지를 설치 해줍니다. yum -y install gcc gcc-c++ httpd-devel pcre-devel wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz tar xvfz pcre-8.00.tar.gz cd pcre-8.43 ./configure --prefix=/usr/local/pcre make make install 이후 아래와 같이 modsecurity2를 직접 설치 합니다. 만약, libxml 에러가 발생할 경우 아래 링크를 참고하여 해결해주신 후 진행 하시면 됩니다. modsecurity libxml 에러 발생 ..

[ModSecurity 2.9] 아파치 modsecurity2 설치 시 에러 "checking for libxml2 config script... no configure: *** xml library not found. configure: error: libxml2 is required"

아파치 modsecurity2 설치 시 에러 "checking for libxml2 config script... no configure: *** xml library not found. configure: error: libxml2 is required" 해당 에러는 modeseucirty2 소스 설치 시 libxml 2.6.29 이하 버전일 경우 발생할 수 있습니다. 아래와 같이 상위 버전을 설치받아 해결하실 수 있습니다. cd /usr/local/src wget ftp://xmlsoft.org/libxml2/libxml2-2.7.7.tar.gz tar xvzf libxml2-2.7.7.tar.gz cd libxml2-2.7.7 ./configure --prefix=/usr/local/xml make..

[Zabbix 4.4] 자빅스 HTTP 응답코드 모니터링 (zabbix http response code monitoring, zabbix http status code monitoring, trigger)

자빅스 로그 파일 모니터링 사전 작업 (agent server) 1. zabbix_agentd.conf 파일 Hostname 수정 자빅스 로그 파일을 모니터링 하기 전에 (agent 서버에서) zabbix_agentd.conf 파일에서 수정해주어야할 부분이 있습니다. Hostname에 자빅스 서버가 아닌, 모니터링될 대상(로컬)의 호스트 명을 작성해 줍니다. 즉, 현재 zabbix.agentd.conf 파일에서 수정하고 있는 자기 자신의 호스트명이 됩니다. ServerActive는 Zabbix Master 서버의 IP 입니다. systemctl restart zabbix-agent 2. Log 파일 권한 수정 이후 모니터링할 로그 파일의 권한을 수정 해줍니다. 필요한 권한은 읽기 입니다. chmod 64..

Monitoring/Zabbix 2020.05.14

[HAProxy] HAProxy URL based routing & load balancing (haproxy 로드밸런싱, haproxy 라우팅)

* selinux 및 firewalld를 disabled 후 진행 했습니다. HAProxy URL based routing & load balancing (haproxy 로드밸런싱, haproxy 라우팅) haproxy 설치 yum -y install haproxy /etc/haproxy/haproxy.cfg 설정 파일 수정 (환경에 따라 도메인 및 routing 또는 loadbalancing으로 써있는 부분을 바꿔서 맞춰주면 됩니다.) defaults log global log 127.0.0.1 local2 mode http option httplog option dontlognull option http-server-close option forwardfor except 127.0.0.0/8 opti..

[ModSecurity 2.9] 모드 시큐리티를 이용해 Apahe POST Body data Logging 하는 방법

Apache POST Body data Logging (mod_security2) yum으로 modsecurity2 설치 후 mod_security2.so 파일이 있는지 확인 합니다. (yum 설치 기준 경로 /etc/httpd/modules) /etc/httpd/conf/httpd.conf 파일로 진입하여 Load_Module mod_security2 modules/mod_security2.so 를 입력하여 모드시큐리티 모듈을 읽어 드립니다. /etc/httpd/conf.d/ 디렉토리로 이동하여 mod_security.conf 파일을 생성 후 아래와 같이 코드를 삽입합니다. SecRuleEngine DetectionOnly SecAuditEngine On SecAuditLog /var/log/httpd..