0

I have a dockerized web application deployed in ECS, and everything works just fine, logging in cloudwatch every request, including a HUGE number of health checks, which are configured to hit the page /health, a blank page.

I'd like to have a solution that is completely automatic and possibly in the Dockerfile

1 Answers1

0

First of all, I need an additional configuration file for Apache, let's call it apacheLogFilter.conf.

The content will be pretty easy, but it could be customized as much as we want, defining custom rules. The trick is defining a custom environment variable that, if present, will stop the logging for that request

SetEnvIf Request_URI "^/health$" dontlog

Once defined this new configuration, we need to plug it into apache directly in the Dockerfile, adding the following rows:

FROM php:7.2-apache

...

# Copy the log-filtering configuration in the right place
COPY  apacheLogFilter.conf /etc/apache2/conf-enabled

# Change the standard logging entry of all the available sites to use the variable 
RUN sed -ri -e 's!combined!combined env=\!dontlog!g' /etc/apache2/sites-available/*.conf

...

In this way, the configuration file will be loaded by apache at startup, each request will check the rules defined, and in case one of them will trigger, the request will not be logged