A custom Docker image based on the official ModSecurity CRS image.
100K+
Based on the official owasp/modsecurity-crs image.
Ad-hoc usage and debugging:
$ docker run -p 80:80 -it -e PARANOIA=4 --rm vshn/modsecurity bash
With a Dockerfile:
FROM vshn/modsecurity:3.1
ENV PARANOIA=1 \
ANOMALY_INBOUND=500 \
ANOMALY_OUTBOUND=400 \
PORT=8000 \
BACKEND=http://facade-svc:9000
VOLUME /opt/modsecurity/rules/before-crs
VOLUME /opt/modsecurity/rules/after-crs
VOLUME /var/log/modsecurity
VOLUME /tmp/modsecurity
With Docker Compose to start a ModSecurity and a httpbin container:
cd v3.1
docker-compose up
When the containers are running, you can make requests like:
curl -i http://localhost:8080/anything
curl -i -H 'Host: vshn.ch' http://localhost:8080/anything
curl -i http://localhost:8080/cookies/set/secret/random-value
For all supported endpoints have a look at httpbin.org.
There are a variety of environment variables available to configure the image.
Most important are the following ones:
1)
1000)
1000)
8080)
SecRuleEngineSecRequestBodyAccessSecResponseBodyAccessSecResponseBodyLimitSecRequestBodyLimitSecRequestBodyNoFilesLimitSecPcreMatchLimitSecPcreMatchLimitRecursionSecDefaultAction tagtx.allowed_methodstx.allowed_request_content_typetx.max_num_argstx.arg_name_lengthtx.total_arg_lengthtx.max_file_sizetx.combined_file_sizesSecDebugLogSecDebugLogLevelSecAuditLogTypeSecAuditLogFormatSecAuditLogSecAuditLogStorageDirFor the default values look at the Dockerfile.
MaxRequestWorkers (in mpm_event module configuration)ServerName (in default site)ServerAdmin (in default site)LogLevel (in default site)ErrorLog (in default site)CustomLog (in default site)CustomLog (in default site)RemoteIPInternalProxy (in default site)X-Forwarded-Proto RequestHeader (in default site)Timeout (in Apache configuration)on)
ProxyPreserveHost (in default site)off)
SSLProxyEngine, can be on or off (in default site). PROXY_PRESERVE_HOST should be turned off to fully validate backend certificates (including host name).none)
SSLProxyVerify, specifies the level of certificate verification (none, optional, require, optional_no_ca).on)
SSLProxyCheckPeerName, can be on or off. Wether the host name of the backend certificate should be checked or not. If PROXY_PRESERVE_HOST is on, this should be off./etc/ssl/certs/ca-certificates.crt)
SSLProxyCACertificateFile (in default site)ProxyTimeout (in default site)For the default values look at the Dockerfile.
127.0.0.1)
3310)
off)
Following the 12-factor app guidelines we're logging audit, error and access logs to the console, and let the cluster's logging stack deal with the output:
You should mount /tmp/modsecurity onto a scratch space, such as an
emptyDir volume. Configured settings are:
/tmp/modsecurity/data)
SecDataDir/tmp/modsecurity/tmp)
SecTmpDir/tmp/modsecurity/upload)
SecUploadDirMount your custom rules
/opt/modsecurity/rules/before-crs/ to load them before the Core Rule Set and/opt/modsecurity/rules/after-crs/ to load them after the CRS has been loaded.All custom rule files must end in .conf in order to be loaded.
This product includes GeoLite2 data created by MaxMind, available from https://www.maxmind.com.
Content type
Image
Digest
sha256:c0ef18761…
Size
91.4 MB
Last updated
about 2 years ago
docker pull vshn/modsecurity