summaryrefslogtreecommitdiffstats
path: root/samples/services/modsecurity/docker/Dockerfile
blob: 5a01f2157c4aefad5ace16e4f6494443c5e89505 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
FROM owasp/modsecurity:v2-ubuntu-apache
MAINTAINER Jing Lu lvjing5@huawei.com

ARG COMMIT=v3.1/dev
ARG REPO=SpiderLabs/owasp-modsecurity-crs
ENV PARANOIA=1

RUN a2enmod rewrite

RUN apt-get update && \
    apt-get -y install python git ca-certificates iproute2 vim

RUN cd /opt && \
  git clone https://github.com/${REPO}.git owasp-modsecurity-crs-3.1 && \
  cd owasp-modsecurity-crs-3.1 && \
  git checkout -qf ${COMMIT}

RUN cd /opt && \
  cp -R /opt/owasp-modsecurity-crs-3.1/ /etc/apache2/modsecurity.d/owasp-crs/ && \
  mv /etc/apache2/modsecurity.d/owasp-crs/crs-setup.conf.example /etc/apache2/modsecurity.d/owasp-crs/crs-setup.conf && \
  cd /etc/apache2/modsecurity.d && \
  printf "include modsecurity.d/owasp-crs/crs-setup.conf\ninclude modsecurity.d/owasp-crs/rules/*.conf" > include.conf && \
  sed -i -e 's/SecRuleEngine DetectionOnly/SecRuleEngine On/g' /etc/apache2/modsecurity.d/modsecurity.conf && \
  a2enmod proxy proxy_http

COPY proxy.conf           /etc/apache2/modsecurity.d/proxy.conf
COPY docker-entrypoint.sh /

RUN chmod 777 /docker-entrypoint.sh

COPY .htaccess            /var/www/html/.htaccess
COPY apache2.conf         /etc/apache2/apache2.conf

EXPOSE 80

ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["apachectl", "-D", "FOREGROUND"]