0

I have a Django application running on aws-elastic-beanstalk. I try to disable the logs caused by my health-checks. The health-checks are already routed to a seperate page.

Elastic-beanstalk uses Apache + mod_wsgi.

Here is a solution that works with nginx servers. I try to create something similar for apache.

I found out that conditional Logs are probably the appropriate way to do it with an Apache Server.

My directory struture looks like the following

/etc/httpd/
  - conf 
      - httpd.conf # main conf
  - conf.d 
      - wsgi.conf # virtual hosts
      - additional config files

my attempt:

files:
  "/etc/httpd/conf.d/disable_health_logs.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
        <IfModule mod_setenvif>
            SetEnvIf Request_URI "^/health/$" dontlog
            CustomLog logs/access_log combined env=!dontlog
        </IfModule>

The additional config disable_health_logs.conf is created but it has no effect. Neither do I see error logs nor a change in the access logs.

In the httpd.conf there is already the following setting:

 CustomLog "logs/access_log" combined

Do I need to override it?

1

I assume you are loading the module somewhere with the following

LoadModule setenvif_module <your_apache_modules_path>/mod_setenvif.so

Also, need to correct your IfModule as shown below (note: the .c at end)

<IfModule mod_setenvif.c>
  SetEnvIf Request_URI "^/health/$" dontlog
  CustomLog logs/access_log combined env=!dontlog
</IfModule>

What you have looks correct otherwise.

  • apachectl -M yields among others: setenvif_module so it is loaded per default – ohlr Mar 24 at 7:51
  • also the .c ending does not change anything... the logs are still appearing – ohlr Mar 24 at 8:22
  • I solved it myself by outcommenting manually in the httpd.conf you were right with the .c however it was not the reason for why it didn't work – ohlr Mar 24 at 11:15
0

So I had another go on this.

The problem really is the setting in the httpd.conf. If I outcomment the line:

#CustomLog "logs/access_log" combined

manually via ssh my settings are used and the health-checks disappear from the logs.

Note that this is not really a permanent solution as beanstalk might spin up a new instance and override the httpd.conf again

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.