Catalog

Nginx — User Guide

Nginx — User Guide

Pack nameNginx
Version1.0.0
VendorNginx
CapabilitiesParser · Streaming Rules · Correlation Rules · Dashboard
CategoriesWeb Server · Reverse Proxy · Network · API Gateway

Overview

Pack cung cấp giám sát bảo mật cho Nginx hoạt động với vai trò reverse proxy, API gateway, hoặc web server, bao gồm:

  • Parser — chuẩn hóa Nginx access log và error log (JSON envelope) sang ECS
  • 5 streaming rules — phát hiện access forbidden, HTTP 4xx/5xx errors, rate limiting triggered, upstream timeout
  • 2 correlation rules — phát hiện rate limit burst (DDoS / API abuse) và HTTP scan burst (4xx flood)
  • 1 dashboard — tổng quan HTTP traffic, error distribution, top IPs, response codes, và upstream health

Yêu cầu trước khi cài đặt

Yêu cầuChi tiết
Nginx version1.18+ (stable)
Log formataccess.log (combined/custom JSON) và error.log
Log shipperFluentd, Fluent Bit, hoặc Filebeat — gửi với field file chứa đường dẫn log
TimestampISO 8601 trong field timestamp của JSON envelope

Định dạng log bắt buộc

{
  "host": "web-proxy-01",
  "file": "/var/log/nginx/access.log",
  "timestamp": "2026-06-23T08:30:00.000Z",
  "message": "<raw nginx log line>"
}

Field file xác định loại log: path chứa access.log → parse access log, path chứa error.log → parse error log. Field host map sang host.name.

Ví dụ log hợp lệ

Access log — request bình thường:

{"host":"web-proxy-01","file":"/var/log/nginx/access.log","timestamp":"2026-06-23T08:30:00.000Z","message":"203.0.113.45 - - [23/Jun/2026:08:30:00 +0000] \"GET /api/v1/users HTTP/1.1\" 200 1847 \"-\" \"Mozilla/5.0 (X11; Linux x86_64)\""}

Access log — 403 Forbidden:

{"host":"web-proxy-01","file":"/var/log/nginx/access.log","timestamp":"2026-06-23T08:30:05.000Z","message":"203.0.113.45 - - [23/Jun/2026:08:30:05 +0000] \"GET /.env HTTP/1.1\" 403 153 \"-\" \"python-requests/2.28.0\""}

Access log — 429 Rate Limited:

{"host":"web-proxy-01","file":"/var/log/nginx/access.log","timestamp":"2026-06-23T08:30:10.000Z","message":"198.51.100.20 - - [23/Jun/2026:08:30:10 +0000] \"POST /api/login HTTP/1.1\" 429 97 \"-\" \"curl/7.68.0\""}

Error log — upstream timeout:

{"host":"web-proxy-01","file":"/var/log/nginx/error.log","timestamp":"2026-06-23T08:31:00.000Z","message":"2026/06/23 08:31:00 [error] 12345#12345: *1001 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 10.0.1.5, server: api.example.com, request: \"GET /api/data HTTP/1.1\", upstream: \"http://10.50.0.10:8080/api/data\""}

Parser nhận diện file path để phân loại access log vs error log. Nếu file không xác định, fallback sang access log parser.


Cài đặt

  1. Vào Marketplace → tìm "Nginx Proxy"Install
  2. Kiểm tra Parsersnginx-proxy-parser đang active
  3. Kiểm tra Detection Rules → filter tag Nginx → 7 rules đang enabled
  4. Mở DashboardsNginx Proxy Security Overview

Parser — Các trường ECS chính

ECS FieldNguồnMô tả
event.actionDerived từ status codeaccess, forbidden, rate_limited, error, upstream_timeout
event.outcomeDerived từ statussuccess (2xx/3xx) / failure (4xx/5xx)
event.categorywebLuôn là web
source.ipRequest client IPIP client gửi request
http.request.methodHTTP methodGET, POST, PUT, DELETE...
url.fullFull request URLURL đầy đủ bao gồm query string
url.pathURL pathChỉ phần path, không có query string
url.domainHost: headerDomain được request
http.response.status_codeHTTP status codeMã HTTP response (200, 403, 429, 500...)
destination.bytesResponse body size (bytes)Kích thước body response gửi về client
http.request.referrerReferer headerURL trang trước
user_agent.originalUser-Agent headerUser agent string nguyên bản
host.namehost fieldHostname của Nginx server
event.durationRequest processing time (ms)Thời gian xử lý request
error.messageError log messageMô tả lỗi từ error.log

Detection Rules

Streaming Rules (5 rules — real-time)

#RuleSeverityMô tả
1Nginx — Access Forbidden by RuleMediumRequest bị Nginx block với 403 — nghi ngờ unauthorized access hoặc path traversal
2Nginx — HTTP 4xx Client ErrorLowHTTP 4xx response — nghi ngờ web scanning hoặc crawling
3Nginx — HTTP 5xx Server ErrorMediumHTTP 5xx server error — ảnh hưởng service availability hoặc nghi ngờ DoS
4Nginx — Rate Limit TriggeredMediumRequest bị rate limit (429) — nghi ngờ API abuse hoặc DDoS
5Nginx — Upstream TimeoutMediumUpstream backend timeout — ảnh hưởng availability hoặc backend quá tải

Correlation Rules (2 rules — pattern)

#RuleSeverityMô tảNgưỡngLookback
6Nginx — Rate Limit Burst (DDoS / API Abuse)HighMột source IP kích hoạt rate limit ≥ 10 lần — DDoS hoặc automated API abuse≥ 10 events15 phút
7Nginx — HTTP Scan Burst (4xx Flood)HighMột source IP tạo ≥ 20 HTTP 4xx responses — web scanning hoặc directory brute-force≥ 20 events10 phút

Dashboard — Nginx Proxy Security Overview

#ChartLoạiMô tả
1HTTP Traffic TrendLINETrend HTTP request volume theo thời gian, phân loại theo outcome
2Total RequestsMETRICTổng số HTTP requests
3Total Errors (4xx+5xx)METRICTổng HTTP error responses
4Rate Limited RequestsMETRICTổng số requests bị rate limit (429)
5HTTP Status DistributionPIEPhân bố theo HTTP status code class
6Event Action DistributionPIEPhân bố loại event (access, forbidden, rate_limited, error)
7Top Source IPs by ErrorBARSource IP tạo nhiều error nhất
8Top Requested URLsBARURL được request nhiều nhất
9HTTP Requests by MethodBARPhân bố HTTP method (GET, POST, PUT...)
10Top User AgentsBARUser agent phổ biến nhất
11Recent 4xx/5xx EventsTABLE50 HTTP error event gần nhất

SOC Triage nhanh:

  1. Metric 3 (Errors) cao → xem Chart 7 (Top Source IPs) để tìm nguồn
  2. Chart 7 → một IP chiếm đa số 4xx → web scanner hoặc attack
  3. Metric 4 (Rate Limited) burst → kiểm tra correlation rule Rate Limit Burst
  4. Chart 8 → URL bất thường như /.env, /admin, /wp-admin → scanning / exploitation attempt

Troubleshooting

Triệu chứngNguyên nhânCách xử lý
Không có eventfile, host, timestamp, message bị thiếuKiểm tra JSON envelope đầy đủ 4 field
Chỉ có error log, không có access logfile path không chứa access.logFluentd/Filebeat phải set file = đường dẫn file log đầy đủ
http.response.status_code = 0Log line không parse đượcKiểm tra Nginx log format — cần combined hoặc custom format có status code
url.domain trốngNginx log không log Host headerThêm $host vào Nginx log format: log_format main '... "$host" ...'
event.duration = 0Log format không có $request_timeThêm $request_time vào Nginx access log format
Dashboard trốngParser chưa activeKiểm tra nginx-proxy-parser.yaml active trong Parsers

Checklist parser:

  • JSON envelope có đủ: host, file, timestamp, message
  • file field chứa đường dẫn đầy đủ đến access.log hoặc error.log
  • Nginx access log format bao gồm: status code, bytes, user-agent, referer
  • nginx-proxy-parser.yaml đang active trong Parsers
  • Log shipper (Fluentd/Filebeat) đang forward log về đúng endpoint

Hỗ trợ

  • Lỗi platform: Mở ticket tại SecOps support portal
  • Góp ý pack: Dùng tính năng feedback trên trang Marketplace
  • Tuning rule: Slack #detection-engineering

Last updated: 2026-06-23 · Vendor: Nginx · Author: secops-team