Building fork of https://hub.docker.com/r/franbuehler/modsecurity-crs-rp
805
This Docker image inherits from the official OWASP Core Rule Set Docker image (ModSecurity + Core Rule Set) and adds some configurable variables and an Apache Reverse Proxy configuration.
The goal is to provide a fully functional CRS in a single command:
See https://coreruleset.org/ for further information.
There are two possible ways to pass ModSecurity tuning rules to the container:
docker run -dti \
--name apachecrsrp \
-p 1.2.3.4:80:8001 \
-v /path/to/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf:/etc/apache2/modsecurity.d/owasp-crs/REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf \
-v /path/to/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf:/etc/apache2/modsecurity.d/owasp-crs/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf \
franbuehler/modsecurity-crs-rp:v3.1
This example can be helpful when no volume mounts are possible (some CI pipelines).
docker create -ti --name apachecrsrp \
-p 1.2.3.4:80:8001 \
franbuehler/modsecurity-crs-rp:v3.1
docker cp /path/to/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf \
apachecrsrp:/etc/apache2/modsecurity.d/owasp-crs/RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf
docker start apachecrsrp
docker run -dti --name apachecrsrp -p 0.0.0.0:80:8001 \
-e PARANOIA=1 \
-e EXECUTING_PARANOIA=2 \
-e ENFORCE_BODYPROC_URLENCODED=1 \
-e ANOMALYIN=10 \
-e ANOMALYOUT=5 \
-e ALLOWED_METHODS="GET POST PUT" \
-e ALLOWED_REQUEST_CONTENT_TYPE="text/xml|application/xml|text/plain" \
-e ALLOWED_REQUEST_CONTENT_TYPE_CHARSET="utf-8|iso-8859-1" \
-e ALLOWED_HTTP_VERSIONS="HTTP/1.1 HTTP/2 HTTP/2.0" \
-e RESTRICTED_EXTENSIONS=".cmd/ .com/ .config/ .dll/" \
-e RESTRICTED_HEADERS="/proxy/ /if/" \
-e STATIC_EXTENSIONS="/.jpg/ /.jpeg/ /.png/ /.gif/" \
-e MAX_NUM_ARGS=128 \
-e ARG_NAME_LENGTH=50 \
-e ARG_LENGTH=200 \
-e TOTAL_ARG_LENGTH=6400 \
-e MAX_FILE_SIZE=100000 \
-e COMBINED_FILE_SIZES=1000000 \
-e BACKEND=http://192.168.192.57:8000 \
-e PORT=8001 \
franbuehler/modsecurity-crs-rp
docker run -dt --name apachecrsrp \
-e PARANOIA=1 \
-e ANOMALYIN=5 \
-e ANOMALYOUT=4 \
-e BACKEND=http://172.17.0.1:8000 \
-e PORT=8001 \
--expose 8001 \
franbuehler/modsecurity-crs-rp
docker run -dti --name apachecrsrp \
-p 1.2.3.4:80:8080 \
-e PARANOIA=1 \
-e EXECUTING_PARANOIA=3 \
-e ANOMALYIN=10 \
-e ANOMALYOUT=5 \
-e MAX_NUM_ARGS=255 \
-e ARG_NAME_LENGTH=100 \
-e ARG_LENGTH=400 \
-e TOTAL_ARG_LENGTH=64000 \
-e MAX_FILE_SIZE=1048576 \
-e COMBINED_FILESIZES=1048576 \
-e BACKEND=http://192.168.192.57:8000 \
-e PORT=8080 franbuehler/modsecurity-crs-rp
See: https://github.com/franbuehler/modsecurity-crs-rp/blob/v3.1/docker-compose.yaml
To run the WAF on OpenShift, following steps are needed:
SSL connection from the route to the WAF.
First we need an SSL certificate for the WAF. This will be added to the OpenShift project as secret.
Copy the created cert and key into the cert-waf directory:
cp new.cert.cert resources/cert-waf/tls.crt
cp new.cert.key resources/cert-waf/tls.key
Create the certificate-waf secret with the tls files.
oc create secret generic certificate-waf --from-file=tls.crt=resources/cert-waf/tls.crt --from-file=tls.key=resources/cert-waf/tls.key --type=kubernetes.io/tls
SSL connection between the WAF (reverse proxy) and the application.
The cert for the communication is mounted into the WAF pod, see secured-routes. This cert is already accessed inside the httpd.conf.
Explanation :: If the destinationCACertificate field is left empty, the router automatically leverages the certificate authority that is generated for service serving certificates, and is injected into every pod as /var/run/secrets/kubernetes.io/serviceaccount/service-ca.crt. This allows new routes that leverage end-to-end encryption without having to generate a certificate for the route. This is useful for custom routers or the F5 router, which might not allow the destinationCACertificate unless the administrator has allowed it.
The httpd.conf file can be mounted into the container by adding a configmap.
With a configmap, the configuration has not to be built into the Docker image. It can easily be updated by changing the configmap.
Create httpd.conf configmap inside the OpenShift project.
oc create configmap httpd.conf --from-file=resources/configmap/httpd.conf
The OpenShift template is provided by this repository.
Minimal parameter is the backend for the WAF (reverse proxy). It consists of the https protocol, the service and port where the application is reachable inside the OpenShift project.
oc process -f resources/modsecurity-waf-template.yaml \
-p BACKEND=https://prometheus-app:8443/ \
| oc apply -f -
Content type
Image
Digest
Size
137.7 MB
Last updated
over 7 years ago
docker pull chrira/modsecurity-crs-rp:openshift