update readme

merge-requests/44/head
Manuel Caballero 2022-11-15 10:07:30 +00:00 committed by Evilham
parent fcff698f6f
commit 2395789c9d
No known key found for this signature in database
GPG Key ID: AE3EE30D970886BF
3 changed files with 80 additions and 19 deletions

14
dd-ctl
View File

@ -880,6 +880,15 @@ enable_waf() {
echo "Done"
}
disable_waf() {
# Enable waf
echo "Disable rules ModSecurity"
docker exec dd-waf-apache bash -c 'sed -i.orig -e "s/modsecurity On/modsecurity Off/" /etc/apache2/sites-enabled/000-default.conf'
echo "Done"
echo "Restart Apache - ModSecurity"
docker restart dd-waf-apache
echo "Done"
}
push_images() {
#
@ -995,9 +1004,12 @@ case "$OPERATION" in
securize)
securize
;;
waf)
enable-waf)
enable_waf
;;
disable-waf)
disable_waf
;;
setconf)
setconf "$@"
;;

View File

@ -0,0 +1,54 @@
# DD - Apache2 ModSecurity + HAProxy
Instalación de los servicios Apache2 ModSecurity y HAProxy.
* En el servicio de Apache2 con ModSecurity V3 se incluyen las reglas OWASP
* En servicio HAProxy actua de frontend de la aplicación, gestiona y negocia el certificado del dominio a través de letsencrypt.
+-----------+ ----------- +-------------+ ---------- +-----------------+\
| Browser | <-https-> | HA proxy | <-http-> | ModSecurity |\
+-----------+ ----------- +-------------+ ---------- +-----------------+
## HAProxy
Podemos encontrar la configuración del servicio en [dd-waf/haproxy](dd-waf/harpoxy)
La versión por defecto que se usara en HAProxy es `haproxy:2.4.12-alpine3.15` pero podemos definir usar otra versión
definiendo el valor de la variable `HAPROXY_IMG` en nuestro fichero dd.conf
La configuración del servicio se encuentra en fichero haproxy.cfg. El fichero ya esta configurado
para enrutar todo el tráfico a través del servicio Apache2-ModSecurity.
El servicio de HAProxy se encarga de negociar y configurar el certicado del dominio de instalación
La comunicación externa es cifrada, pero internamente la comunción usa el protocolo http
## Apache - ModSecurity
Podemos encontrar la configuración del servicio en [dd-waf/haproxy](dd-waf/harpoxy)
Tenemos diferentes ficheros para configurar este servicio
* En el fichero 000-default.conf tendremos la configuración del servidor web Apache2.
* En el fichero crs-setup.conf configuramos OWASP ModSecurity Core Rule Set ver.3.2.0
* En el fichero modsec_rules.conf incluimos los ficheros necesarios del owasp servicio de Apache2
* En el fichero rules_apps.conf se configuran los falsos positivos, de las diferentes aplicaciones, que se tienen idenficados hasta el momento.
## Configuración
En la instalación el ModSecurity se encuentra deshabilitado para no interferir en el proceso de setup inicial del DD.
Una vez finalizada la parte de setup, podemos activarlo o desactivarlo según necesitemos,
### Activar ModSecurity con las reglas OWASP
```
./dd-ctl enable_waf
```
### Desactivar ModSecurity con las reglas OWASP
```
./dd-ctl disable_waf
```

View File

@ -1,38 +1,32 @@
# Install Modsecurity in a Docker container
FROM ubuntu:20.04 as production
ARG DEBIAN_FRONTEND=noninteractive
# update/upgrade your system
RUN apt-get update -y
# update/upgrade your system
# Install Required Dependencies
RUN apt-get install -y g++ flex bison curl apache2-dev \
RUN apt-get update && apt-get install -y \
g++ flex bison curl apache2-dev \
doxygen libyajl-dev ssdeep liblua5.2-dev \
libgeoip-dev libtool dh-autoreconf \
libcurl4-gnutls-dev libxml2 libpcre++-dev \
libxml2-dev git wget tar apache2
# certbot python3-certbot-apache
libxml2-dev git wget tar apache2 \
&& rm -rf /var/lib/apt/lists/*
# Download LibModsecurity
RUN wget https://github.com/SpiderLabs/ModSecurity/releases/download/v3.0.8/modsecurity-v3.0.8.tar.gz
# Extract the Downloaded File
RUN tar xzf modsecurity-v3.0.8.tar.gz && rm -rf modsecurity-v3.0.8.tar.gz
# Compile and Install LibModsecurity
RUN cd modsecurity-v3.0.8 && \
# Download LibModsecurity. Extract the Downloaded File. Compile and Install LibModsecurity
RUN wget https://github.com/SpiderLabs/ModSecurity/releases/download/v3.0.8/modsecurity-v3.0.8.tar.gz \
&& tar xzf modsecurity-v3.0.8.tar.gz && rm -rf modsecurity-v3.0.8.tar.gz \
&& cd modsecurity-v3.0.8 && \
./build.sh && ./configure && \
make && make install
# Install ModSecurity-Apache Connector
RUN cd ~ && git clone https://github.com/SpiderLabs/ModSecurity-apache
RUN cd ~/ModSecurity-apache && \
RUN cd ~ && git clone https://github.com/SpiderLabs/ModSecurity-apache \
&& cd ~/ModSecurity-apache && \
./autogen.sh && \
./configure --with-libmodsecurity=/usr/local/modsecurity/ && \
make && \
make install
# logs should go to stdout / stderr
RUN set -ex \
&& ln -sfT /dev/stderr /var/log/apache2/error.log \
@ -47,10 +41,11 @@ RUN mkdir -p /etc/apache2/modsecurity.d/dd-rules && \
cp modsecurity-v3.0.8/modsecurity.conf-recommended /etc/apache2/modsecurity.d/modsecurity.conf && \
cp modsecurity-v3.0.8/unicode.mapping /etc/apache2/modsecurity.d/ && \
sed -i 's/SecRuleEngine DetectionOnly/SecRuleEngine On/' /etc/apache2/modsecurity.d/modsecurity.conf
ADD modsec_rules.conf /etc/apache2/modsecurity.d/
# Install OWASP ModSecurity Core Rule Set (CRS) on Ubuntu
RUN git clone https://github.com/SpiderLabs/owasp-modsecurity-crs.git /etc/apache2/modsecurity.d/owasp-crs
RUN git clone --depth=1 https://github.com/SpiderLabs/owasp-modsecurity-crs.git /etc/apache2/modsecurity.d/owasp-crs
ADD crs-setup.conf /etc/apache2/modsecurity.d/owasp-crs/crs-setup.conf
# Activate ModSecurity