NGINX 로그 수집
이 문서에서는 Bindplane 에이전트를 사용하여 NGINX 로그를 Google Security Operations로 수집하는 방법을 설명합니다.
NGINX는 HTTP 액세스 이벤트, 오류 이벤트, 인증 활동, 프로세스 정보에 대한 syslog 메시지를 생성하는 웹 서버 및 역방향 프록시입니다. 파서는 grok 패턴을 사용하여 여러 로그 형식 (syslog, JSON, 액세스 로그)에서 필드를 추출하고 이를 통합 데이터 모델 (UDM)에 매핑합니다.
시작하기 전에
다음 기본 요건이 충족되었는지 확인합니다.
- Google SecOps 인스턴스
- Windows Server 2016 이상 또는
systemd가 설치된 Linux 호스트 - Bindplane 에이전트와 NGINX 서버 간의 네트워크 연결
- 프록시 뒤에서 실행하는 경우 Bindplane 에이전트 요구사항에 따라 방화벽 포트가 열려 있는지 확인합니다.
- NGINX 호스트에 대한 관리 액세스
Google SecOps 수집 인증 파일 가져오기
- Google SecOps 콘솔에 로그인합니다.
- SIEM 설정 > 수집 에이전트로 이동합니다.
- 수집 인증 파일을 다운로드합니다.
Bindplane 에이전트가 설치될 시스템에 파일을 안전하게 저장합니다.
Google SecOps 고객 ID 가져오기
- Google SecOps 콘솔에 로그인합니다.
- SIEM 설정 > 프로필로 이동합니다.
조직 세부정보 섹션에서 고객 ID를 복사하여 저장합니다.
Bindplane 에이전트 설치
다음 안내에 따라 Windows 또는 Linux 운영체제에 Bindplane 에이전트를 설치합니다.
Windows 설치
- 명령 프롬프트 또는 PowerShell을 관리자로 엽니다.
다음 명령어를 실행합니다.
msiexec /i "https://github.com/observIQ/bindplane-agent/releases/latest/download/observiq-otel-collector.msi" /quiet설치가 완료될 때까지 기다립니다.
다음을 실행하여 설치를 확인합니다.
sc query observiq-otel-collector서비스가 실행 중으로 표시되어야 합니다.
Linux 설치
- 루트 또는 sudo 권한으로 터미널을 엽니다.
다음 명령어를 실행합니다.
sudo sh -c "$(curl -fsSlL https://github.com/observiq/bindplane-agent/releases/latest/download/install_unix.sh)" install_unix.sh설치가 완료될 때까지 기다립니다.
다음을 실행하여 설치를 확인합니다.
sudo systemctl status observiq-otel-collector서비스가 active (running)으로 표시되어야 합니다.
추가 설치 리소스
추가 설치 옵션 및 문제 해결은 Bindplane 에이전트 설치 가이드를 참고하세요.
syslog를 수집하여 Google SecOps로 전송하도록 Bindplane 에이전트 구성
구성 파일 찾기
Linux:
sudo nano /opt/observiq-otel-collector/config.yamlWindows:
notepad "C:\Program Files\observIQ OpenTelemetry Collector\config.yaml"
구성 파일 설정
config.yaml의 전체 내용을 다음 구성으로 바꿉니다.receivers: udplog: listen_address: "0.0.0.0:514" exporters: chronicle/nginx: compression: gzip creds_file_path: '/etc/bindplane-agent/ingestion-auth.json' customer_id: '<customer_id>' endpoint: malachiteingestion-pa.googleapis.com log_type: NGINX raw_log_field: body service: pipelines: logs/nginx_to_chronicle: receivers: - udplog exporters: - chronicle/nginx
구성 매개변수
다음 자리표시자를 바꿉니다.
수신기 구성:
listen_address: 리슨할 IP 주소 및 포트입니다.0.0.0.0: 모든 인터페이스에서 수신 대기 (권장)- 포트
514는 표준 syslog 포트입니다 (Linux에서 루트 필요, 비루트의 경우1514사용).
내보내기 도구 구성:
creds_file_path: 수집 인증 파일의 전체 경로입니다.- Linux:
/etc/bindplane-agent/ingestion-auth.json - Windows:
C:\Program Files\observIQ OpenTelemetry Collector\ingestion-auth.json
- Linux:
customer_id: Google SecOps 콘솔에서 복사한 고객 IDendpoint: 리전 엔드포인트 URL:- 미국:
malachiteingestion-pa.googleapis.com - 유럽:
europe-malachiteingestion-pa.googleapis.com - 아시아:
asia-southeast1-malachiteingestion-pa.googleapis.com - 전체 목록은 리전 엔드포인트를 참고하세요.
- 미국:
구성 파일 저장
- 수정 후 파일을 저장합니다.
- Linux:
Ctrl+O,Enter,Ctrl+X순서로 누릅니다. - Windows: 파일 > 저장을 클릭합니다.
- Linux:
변경사항을 적용하려면 Bindplane 에이전트를 다시 시작하세요.
Linux에서 Bindplane 에이전트를 다시 시작하려면 다음 명령어를 실행합니다.
sudo systemctl restart observiq-otel-collector서비스가 실행 중인지 확인합니다.
sudo systemctl status observiq-otel-collector로그에서 오류를 확인합니다.
sudo journalctl -u observiq-otel-collector -f
Windows에서 Bindplane 에이전트를 다시 시작하려면 다음 옵션 중 하나를 선택합니다.
관리자 권한으로 명령 프롬프트 또는 PowerShell:
net stop observiq-otel-collector && net start observiq-otel-collector서비스 콘솔:
Win+R키를 누르고services.msc을 입력한 다음 Enter 키를 누릅니다.- observIQ OpenTelemetry Collector를 찾습니다.
- 마우스 오른쪽 버튼을 클릭하고 다시 시작을 선택합니다.
서비스가 실행 중인지 확인합니다.
sc query observiq-otel-collector로그에서 오류를 확인합니다.
type "C:\Program Files\observIQ OpenTelemetry Collector\log\collector.log"
로그를 Bindplane으로 전달하도록 NGINX 구성
NGINX 구성 파일 (예:
/etc/nginx/nginx.conf)을 엽니다.sudo vi /etc/nginx/nginx.conf구성을 수정하여
<BINDPLANE_SERVER>및<BINDPLANE_PORT>을 값으로 바꿉니다.http { access_log syslog:server=<BINDPLANE_SERVER>:<BINDPLANE_PORT>,facility=local7,tag=nginx_access; error_log syslog:server=<BINDPLANE_SERVER>:<BINDPLANE_PORT>,facility=local7,tag=nginx_error; }NGINX를 다시 시작하여 변경사항을 적용합니다.
sudo systemctl reload nginx
UDM 매핑 테이블
| 로그 필드 | UDM 매핑 | 논리 |
|---|---|---|
_Internal_WorkspaceResourceId |
target.resource.product_object_id |
직접 매핑됨 |
Computer |
principal.asset.hostname |
직접 매핑됨 |
Facility |
additional.fields[시설] |
직접 매핑됨 |
HostName |
principal.asset.hostname |
src_ip가 없으면 직접 매핑됩니다. |
ProcessName |
principal.application |
직접 매핑됨 |
SeverityLevel |
security_result.severity |
값이 info인 경우 INFORMATIONAL에 매핑됩니다. |
SourceSystem |
principal.asset.platform |
값이 Linux와 일치하면 LINUX에 매핑됩니다. |
SyslogMessage |
여러 필드 | grok을 사용하여 time, method, target_path, protocol, response_code, referral_url, user_agent, target_ip, target_host, cache 추출 |
TenantId |
additional.fields[TenantId] |
직접 매핑됨 |
acct |
principal.user.user_id |
비어 있지 않거나 ?인 경우 직접 매핑됨 |
addr |
principal.asset.ip |
직접 매핑됨 |
audit_epoch |
metadata.event_timestamp |
UNIX 형식을 사용하여 타임스탬프로 변환되었습니다. 나노초는 원래 로그 메시지에서 추출됩니다. |
cache |
additional.fields[cache] |
직접 매핑됨 |
collection_time.nanos |
metadata.event_timestamp.nanos |
사용 가능한 경우 이벤트 타임스탬프의 나노초에 사용됩니다. |
collection_time.seconds |
metadata.event_timestamp.seconds |
사용 가능한 경우 이벤트 타임스탬프의 초에 사용됩니다. |
data |
여러 필드 | 로그 형식 (Syslog, JSON 또는 기타)에 따라 다르게 파싱되는 기본 데이터 소스 |
exe |
target.process.command_line |
백슬래시와 따옴표를 삭제한 후 직접 매핑됨 |
hostname |
principal.asset.hostname 또는 principal.asset.ip |
IP 주소인 경우 principal.asset.ip에 매핑됩니다. 그렇지 않으면 principal.asset.hostname으로 매핑됩니다. |
msg |
metadata.description |
설명으로 직접 매핑됨 |
node |
target.asset.hostname |
직접 매핑됨 |
pid |
target.process.pid |
직접 매핑됨 |
protocol |
network.application_protocol |
값이 HTTP와 일치하는 경우 HTTP에 매핑됩니다. |
referral_url |
network.http.referral_url |
비어 있지 않거나 -인 경우 직접 매핑됨 |
res |
security_result.action_details |
직접 매핑됨 |
response_code |
network.http.response_code |
정수로 직접 매핑되고 변환됨 |
ses |
network.session_id |
직접 매핑됨 |
src_ip |
principal.asset.ip |
직접 매핑됨 |
target_host |
target.asset.hostname |
직접 매핑됨 |
target_ip |
target.asset.ip |
문자열 표현을 JSON 배열로 변환한 후 개별 IP를 추출하여 직접 매핑 |
target_path |
target.url |
직접 매핑됨 |
time |
metadata.event_timestamp |
dd/MMM/yyyy:HH:mm:ss Z 형식을 사용하여 타임스탬프를 추출하기 위해 파싱됨 |
user_agent |
network.http.user_agent |
비어 있지 않거나 -인 경우 직접 매핑됨 |
metadata.event_type |
처음에는 GENERIC_EVENT로 설정되며 terminal, protocol와 같은 다른 필드에 따라 덮어쓸 수 있습니다. 기본 grok 패턴이 일치하지 않으면 기본값은 USER_UNCATEGORIZED입니다. protocol이 HTTP이고 target_ip이 있는 경우 NETWORK_HTTP로 설정하고, protocol이 HTTP이지만 target_ip이 없는 경우 STATUS_UPDATE로 설정합니다. |
|
metadata.log_type |
NGINX로 설정 |
|
metadata.product_name |
NGINX로 설정 |
|
metadata.vendor_name |
NGINX로 설정 |
|
network.ip_protocol |
terminal이 sshd 또는 ssh인 경우 또는 기본 grok 패턴이 일치하지 않는 경우 TCP로 설정합니다. |
|
principal.asset_id |
terminal이 sshd 또는 ssh이면 GCP.GCE:0001로 설정합니다. 기본 grok 패턴이 일치하지 않는 경우 GCP.GCE:0002로 설정합니다. |
|
extensions.auth.type |
terminal이 sshd 또는 ssh이면 MACHINE로 설정합니다. |
도움이 더 필요하신가요? 커뮤니티 회원 및 Google SecOps 전문가에게 문의하여 답변을 받으세요.