Skip to content
This repository has been archived by the owner on Nov 26, 2022. It is now read-only.

Use cleaner approach to include ModSecurity config #34

Merged
merged 2 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 11 additions & 15 deletions v2-apache/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,19 @@ COPY --from=build /usr/local/lib/libfuzzy.so.2.1.0 /
COPY --from=build /usr/local/bin/ssdeep /usr/local/bin/ssdeep
COPY --from=build /usr/share/TLS/server.key /usr/local/apache2/conf/server.key
COPY --from=build /usr/share/TLS/server.crt /usr/local/apache2/conf/server.crt
COPY httpd-logging-before-modsec.conf /usr/local/apache2/conf/extra/httpd-logging-before-modsec.conf
COPY httpd-logging-after-modsec.conf /usr/local/apache2/conf/extra/httpd-logging-after-modsec.conf

RUN ln -s libfuzzy.so.2.1.0 /usr/local/lib/libfuzzy.so && \
ln -s libfuzzy.so.2.1.0 /usr/local/lib/libfuzzy.so.2 && \
ldconfig
RUN ln -s libfuzzy.so.2.1.0 /usr/local/lib/libfuzzy.so \
&& ln -s libfuzzy.so.2.1.0 /usr/local/lib/libfuzzy.so.2 \
&& ldconfig

RUN sed -i -e 's/#LoadModule unique_id_module/LoadModule unique_id_module/g' /usr/local/apache2/conf/httpd.conf && \
sed -i -e 's/ServerTokens Full/ServerTokens Prod/g' /usr/local/apache2/conf/extra/httpd-default.conf && \
sed -i -e 's/#CustomLog "logs\/access_log" combined/Include conf\/extra\/httpd-logging-before-modsec.conf/' /usr/local/apache2/conf/httpd.conf && \
echo "LoadModule security2_module /usr/local/apache2/modules/mod_security2.so" >> /usr/local/apache2/conf/httpd.conf && \
echo "Include conf/extra/httpd-default.conf" >> /usr/local/apache2/conf/httpd.conf && \
echo "<IfModule security2_module>\nInclude /etc/modsecurity.d/include.conf\n</IfModule>" >> /usr/local/apache2/conf/httpd.conf && \
echo "include \"/etc/modsecurity.d/modsecurity.conf\"" > /etc/modsecurity.d/include.conf && \
echo "Include conf/extra/httpd-logging-after-modsec.conf" >> /usr/local/apache2/conf/httpd.conf && \
echo "ServerName \${SERVERNAME}" >> /usr/local/apache2/conf/httpd.conf && \
echo "hello world" > /usr/local/apache2/htdocs/index.html
RUN sed -i -E 's|(ServerTokens) Full|\1 Prod|' /usr/local/apache2/conf/extra/httpd-default.conf \
&& sed -i -E 's|#(Include conf/extra/httpd-default.conf)|\1|' /usr/local/apache2/conf/httpd.conf \
&& sed -i -E 's|#(ServerName) www.example.com:80|\1 ${SERVERNAME}|' /usr/local/apache2/conf/httpd.conf \
&& sed -i -E 's|#(LoadModule unique_id_module)|\1|' /usr/local/apache2/conf/httpd.conf \
&& echo 'Include conf/extra/httpd-modsecurity.conf' >> /usr/local/apache2/conf/httpd.conf \
&& echo 'LoadModule security2_module /usr/local/apache2/modules/mod_security2.so' > /usr/local/apache2/conf/extra/httpd-modsecurity.conf \
&& echo 'Include /etc/modsecurity.d/include.conf' >> /usr/local/apache2/conf/extra/httpd-modsecurity.conf \
&& echo 'Include /etc/modsecurity.d/modsecurity.conf' > /etc/modsecurity.d/include.conf

RUN if [ "$SETTLS" = "True" ]; then \
echo "setting TLS"; \
Expand Down
Empty file.
18 changes: 0 additions & 18 deletions v2-apache/httpd-logging-before-modsec.conf

This file was deleted.