diff --git a/README.md b/README.md index 71a31359..03eec530 100644 --- a/README.md +++ b/README.md @@ -403,6 +403,10 @@ docker build -t my-modsec . -f docker run -p 8080:8080 -e BACKEND=http://example.com my-modsec ``` +### Standalone mode (no backend) + +If you don't have a backend to proxy to (e.g. a quick demo, or protecting a plain static site), override `default.conf.template` to drop the `proxy_backend.conf` include and serve files directly instead. See [`examples/standalone-static`](examples/standalone-static) for a working `docker compose` setup. + ## ServerName It is often convenient to set your server name (set to `localhost` by default). To do this simply use the `SERVER_NAME` environment variable. diff --git a/examples/standalone-static/docker-compose.yaml b/examples/standalone-static/docker-compose.yaml new file mode 100644 index 00000000..441a2c78 --- /dev/null +++ b/examples/standalone-static/docker-compose.yaml @@ -0,0 +1,20 @@ +# Runs the CRS nginx image standalone: serving static files directly, with no +# backend to proxy to. Useful for a quick demo/CTF-style WAF, or protecting a +# plain static site without a second container. +# +# By default this image is a reverse proxy and requires BACKEND to point at a +# real web server (see README.md#proxy-configuration). This override drops +# the `proxy_backend.conf` include from `default.conf.template` so nginx +# serves ./html directly instead. +# +# Usage: +# docker compose up +# curl http://localhost:8080/ +services: + standalone: + image: owasp/modsecurity-crs:nginx-alpine + volumes: + - ./templates/conf.d/default.conf.template:/etc/nginx/templates/conf.d/default.conf.template:ro + - ./html:/usr/share/nginx/html:ro + ports: + - "8080:8080" diff --git a/examples/standalone-static/html/index.html b/examples/standalone-static/html/index.html new file mode 100644 index 00000000..d0ee7262 --- /dev/null +++ b/examples/standalone-static/html/index.html @@ -0,0 +1,9 @@ + + +
Served directly by the modsecurity-crs nginx image, no backend required.
+Try: curl "http://localhost:8080/?id=1'%20OR%20'1'='1" to see ModSecurity block it.