Skip to main content

Django package to restrict access just to cloudflare workers

Project description

Overview

The django-cloudflare-restrictor package provides a convient way to restrict access to your application server, such that it will only respond to requests that come via cloudflare's network.

Installation

Install the package from pypi

pip install django-cloudflare-restrictor

Add to INSTALLED APPS in your settings file

INSTALLED_APPS = [
    'django_cloudflare_restrictor',
    ...

And add to MIDDLEWARE in your settings file

MIDDLEWARE = [
    'django_cloudflare_restrictor.middleware.CloudflareRestrictorMiddleware',
    ...
 ]

Set the additional settings as desired

CLOUDFLARE_RESTRICTOR_ENABLED = True
CLOUDFLARE_RESTRICTOR_ADDITIONAL_NETWORKS = ["127.0.0.0/8"]
CLOUDFLARE_RESTRICTOR_EXCLUDE_PATHS = [
    '^/cron/$',
]

If you want to confirm that the IP blocks stored in the django-cloudflare-restrictor package are up to date you can use the check_cloudflare_ips command. This will log a warning if the IP addresses are out of date.

python manage.py check_cloudflare_ips

Based on historical evidence, it appears that Cloudflare gives around 1 month's advance notice of IP address changes, by publishing the new addresses in advance on their site. Updates to these lists are very infrequent (approx once per every 2 years)

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-cloudflare-restrictor-1.0.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_cloudflare_restrictor-1.0.2-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file django-cloudflare-restrictor-1.0.2.tar.gz.

File metadata

File hashes

Hashes for django-cloudflare-restrictor-1.0.2.tar.gz
Algorithm Hash digest
SHA256 111b9dbb647eb44b7cb212eb326792545b3c4c7e1009fb624df5da7acd4b8100
MD5 45a28ab155c332e692a996bd92f0465b
BLAKE2b-256 161fe0d211b3a9ad7207aba14b09c98d71d5c7c2774dec4d7fca6527d435f18b

See more details on using hashes here.

File details

Details for the file django_cloudflare_restrictor-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_cloudflare_restrictor-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 988103d32d18d3d97e50727d91edf302a9a4df99c135c588869d7d263cd0b0a8
MD5 ac2defc0d50c4c7056c52f036ebe608d
BLAKE2b-256 8397343b31a410b4f1d0446642b5226632d8d2b70db431664f99af406b51bd06

See more details on using hashes here.

Supported by

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