Disable health-check logging in AWS ELB Django Application

ohl*_*hlr 6 apache django mod-wsgi amazon-web-services amazon-elastic-beanstalk

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.

The following code 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
Run Code Online (Sandbox Code Playgroud)

my attempt:

files:
  "/etc/httpd/conf.d/disable_health_logs.conf":
    mode: "000644"
    owner: root
    group: root
    content: |
        SetEnvIf Request_URI "^/health/$" dontlog
        CustomLog logs/access_log common env=!dontlog
Run Code Online (Sandbox Code Playgroud)

The file 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
Run Code Online (Sandbox Code Playgroud)

Do I need to override it?

ohl*_*hlr 1

所以我又做了一次。

问题确实出在httpd.conf. 如果我评论该行:

#CustomLog "logs/access_log" combined
Run Code Online (Sandbox Code Playgroud)

通过 ssh 手动使用我的设置,并且运行状况检查将从日志中消失。

请注意,这并不是真正的永久解决方案,因为 beanstalk 可能会启动一个新实例并再次覆盖 httpd.conf。