Catalog
Nginx — User Guide
Nginx — User Guide
| Pack name | Nginx |
| Version | 1.0.0 |
| Vendor | Nginx |
| Capabilities | Parser · Streaming Rules · Correlation Rules · Dashboard |
| Categories | Web 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ầu | Chi tiết |
|---|---|
| Nginx version | 1.18+ (stable) |
| Log format | access.log (combined/custom JSON) và error.log |
| Log shipper | Fluentd, Fluent Bit, hoặc Filebeat — gửi với field file chứa đường dẫn log |
| Timestamp | ISO 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
filexác định loại log: path chứaaccess.log→ parse access log, path chứaerror.log→ parse error log. Fieldhostmap sanghost.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
filepath để phân loại access log vs error log. Nếufilekhông xác định, fallback sang access log parser.
Cài đặt
- Vào Marketplace → tìm "Nginx Proxy" → Install
- Kiểm tra Parsers →
nginx-proxy-parserđang active - Kiểm tra Detection Rules → filter tag Nginx → 7 rules đang enabled
- Mở Dashboards → Nginx Proxy Security Overview
Parser — Các trường ECS chính
| ECS Field | Nguồn | Mô tả |
|---|---|---|
event.action | Derived từ status code | access, forbidden, rate_limited, error, upstream_timeout |
event.outcome | Derived từ status | success (2xx/3xx) / failure (4xx/5xx) |
event.category | web | Luôn là web |
source.ip | Request client IP | IP client gửi request |
http.request.method | HTTP method | GET, POST, PUT, DELETE... |
url.full | Full request URL | URL đầy đủ bao gồm query string |
url.path | URL path | Chỉ phần path, không có query string |
url.domain | Host: header | Domain được request |
http.response.status_code | HTTP status code | Mã HTTP response (200, 403, 429, 500...) |
destination.bytes | Response body size (bytes) | Kích thước body response gửi về client |
http.request.referrer | Referer header | URL trang trước |
user_agent.original | User-Agent header | User agent string nguyên bản |
host.name | host field | Hostname của Nginx server |
event.duration | Request processing time (ms) | Thời gian xử lý request |
error.message | Error log message | Mô tả lỗi từ error.log |
Detection Rules
Streaming Rules (5 rules — real-time)
| # | Rule | Severity | Mô tả |
|---|---|---|---|
| 1 | Nginx — Access Forbidden by Rule | Medium | Request bị Nginx block với 403 — nghi ngờ unauthorized access hoặc path traversal |
| 2 | Nginx — HTTP 4xx Client Error | Low | HTTP 4xx response — nghi ngờ web scanning hoặc crawling |
| 3 | Nginx — HTTP 5xx Server Error | Medium | HTTP 5xx server error — ảnh hưởng service availability hoặc nghi ngờ DoS |
| 4 | Nginx — Rate Limit Triggered | Medium | Request bị rate limit (429) — nghi ngờ API abuse hoặc DDoS |
| 5 | Nginx — Upstream Timeout | Medium | Upstream backend timeout — ảnh hưởng availability hoặc backend quá tải |
Correlation Rules (2 rules — pattern)
| # | Rule | Severity | Mô tả | Ngưỡng | Lookback |
|---|---|---|---|---|---|
| 6 | Nginx — Rate Limit Burst (DDoS / API Abuse) | High | Một source IP kích hoạt rate limit ≥ 10 lần — DDoS hoặc automated API abuse | ≥ 10 events | 15 phút |
| 7 | Nginx — HTTP Scan Burst (4xx Flood) | High | Một source IP tạo ≥ 20 HTTP 4xx responses — web scanning hoặc directory brute-force | ≥ 20 events | 10 phút |
Dashboard — Nginx Proxy Security Overview
| # | Chart | Loại | Mô tả |
|---|---|---|---|
| 1 | HTTP Traffic Trend | LINE | Trend HTTP request volume theo thời gian, phân loại theo outcome |
| 2 | Total Requests | METRIC | Tổng số HTTP requests |
| 3 | Total Errors (4xx+5xx) | METRIC | Tổng HTTP error responses |
| 4 | Rate Limited Requests | METRIC | Tổng số requests bị rate limit (429) |
| 5 | HTTP Status Distribution | PIE | Phân bố theo HTTP status code class |
| 6 | Event Action Distribution | PIE | Phân bố loại event (access, forbidden, rate_limited, error) |
| 7 | Top Source IPs by Error | BAR | Source IP tạo nhiều error nhất |
| 8 | Top Requested URLs | BAR | URL được request nhiều nhất |
| 9 | HTTP Requests by Method | BAR | Phân bố HTTP method (GET, POST, PUT...) |
| 10 | Top User Agents | BAR | User agent phổ biến nhất |
| 11 | Recent 4xx/5xx Events | TABLE | 50 HTTP error event gần nhất |
SOC Triage nhanh:
- Metric 3 (Errors) cao → xem Chart 7 (Top Source IPs) để tìm nguồn
- Chart 7 → một IP chiếm đa số 4xx → web scanner hoặc attack
- Metric 4 (Rate Limited) burst → kiểm tra correlation rule
Rate Limit Burst - Chart 8 → URL bất thường như
/.env,/admin,/wp-admin→ scanning / exploitation attempt
Troubleshooting
| Triệu chứng | Nguyên nhân | Cách xử lý |
|---|---|---|
| Không có event | file, host, timestamp, message bị thiếu | Kiểm tra JSON envelope đầy đủ 4 field |
| Chỉ có error log, không có access log | file path không chứa access.log | Fluentd/Filebeat phải set file = đường dẫn file log đầy đủ |
http.response.status_code = 0 | Log line không parse được | Kiểm tra Nginx log format — cần combined hoặc custom format có status code |
url.domain trống | Nginx log không log Host header | Thêm $host vào Nginx log format: log_format main '... "$host" ...' |
event.duration = 0 | Log format không có $request_time | Thêm $request_time vào Nginx access log format |
| Dashboard trống | Parser chưa active | Kiểm tra nginx-proxy-parser.yaml active trong Parsers |
Checklist parser:
- JSON envelope có đủ:
host,file,timestamp,message -
filefield chứa đường dẫn đầy đủ đếnaccess.loghoặcerror.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