Skip to main content

White list internal hosts that perform health-checks

Project description

Django Allow Health-Checks


Kubernetes, load-balancers and other PaaS have a concept of a health check. These are simple GET requests against an endpoint that you define which tells the orchestrator if a web worker is healthy or not. The problem is that these requests come from within the same network running your app using an non-deterministic hostname or IP address. So instead of making your allowed hosts wide open with ['*'] (to allow any requests to get by), you can simply install this package to allow these requests to occur without introducing more technical/security risks then necessary.

For example, given a kubernetes deployment with the following details:

#... other details
      - name: app
            path: /health-check/
            port: 8000
            - name: X-Health
              value:  XYZ-123
          initialDelaySeconds: 3
          periodSeconds: 60
        imagePullPolicy: Always

You can allow these requests to get by by simply adding this to your settings



Install django-allow-healthchecks

pip3 install django-allow-healthchecks

Add the class to your middleware, ideally first in the list

    'django_allow_healthchecks.middleware.ByPassForHealthChecks', # <~ Add this 

Assign your magical header value



Python3.5+ + Django 2.2+! Get on board!!

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-allow-healthchecks-0.1.4.tar.gz (5.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page