An open API service indexing awesome lists of open source software.

https://github.com/cloudymax/modsecurity-dashboard

A Grafana dashboard for JSON formatted kubernetes ingress-nginx modsecurity logs for use with Kuber-Pormetheus-Stack and Loki-Stack
https://github.com/cloudymax/modsecurity-dashboard

Last synced: about 1 year ago
JSON representation

A Grafana dashboard for JSON formatted kubernetes ingress-nginx modsecurity logs for use with Kuber-Pormetheus-Stack and Loki-Stack

Awesome Lists containing this project

README

          

# Modsecurity Dashboard

A Grafana dashboard for JSON-formatted kubernetes ingress-nginx modsecurity logs.

## Acknowledgement

This dashbboard is a heavily-modified derivative of the [NGINX ModSecurity OWASP CRS V0.0](https://grafana.com/grafana/dashboards/15495-nginx-modsecurity-owasp-crs-v0-0/) dashboard by [coffeeflash](https://github.com/coffeeflash). They discus more about it's creation in [this blog post](https://tobisyurt.net/modsecurity-nginx). I have modified the dashboard to use `JSON` logs collected from `/dev/stdout` and changed some formatting for readability.

Screenshot 2023-05-09 at 15 48 26

## Requirements

- [Kubernetes ingress-nginx](https://github.com/kubernetes/ingress-nginx) with metrics and modsecurity enabled
- Modesecurity log format set to `JSON`
- Modsecurity log output path `/dev/stdout`
- [Kube-Prometheus-Stack](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack) (Prometheus, Grafana)
- [Loki-Stack](https://github.com/grafana/helm-charts/tree/main/charts/loki-stack) (Promtail, Loki)

## Enable NGINX MOD Security + Metrics

1. Update the Nginx configmap:

```bash
kubectl edit configmap -n ingress-nginx ingress-nginx-controller
```

2. Enable modsecurity:

```yaml
apiVersion: v1
data:
# ...
allow-snippet-annotations: "true"
enable-modsecurity: "true"
enable-owasp-modsecurity-crs: "true"
load-balance: ewma
modsecurity-snippet: |-
SecRuleEngine DetectionOnly
SecAuditEngine RelevantOnly
SecStatusEngine On
SecRequestBodyAccess On
SecAuditLog /dev/stdout
SecAuditLogFormat JSON
# ...
```

3. Expose metrics

```bash
helm upgrade ingress-nginx ingress-nginx \
--repo https://kubernetes.github.io/ingress-nginx \
--namespace ingress-nginx \
--set controller.metrics.enabled=true \
--set-string controller.podAnnotations."prometheus\.io/scrape"="true" \
--set-string controller.podAnnotations."prometheus\.io/port"="10254"
```