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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django-cloudflare-restrictor-1.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7f76d96ce894bbd4336629dd6d4859c8c81e70bda363aac03904e124ede6da4 |
|
MD5 | 0fe9045a2c1f708e5b9ef92735fbc81d |
|
BLAKE2b-256 | 5f60bfca5e31c2fae5c30f588529d75591f2b31ced12d57fb0287a06d6ac1918 |
Hashes for django_cloudflare_restrictor-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1aeb35b626e7e1066b04c5ae4ce36df8999538b1e11530c0ec9218ab55f54242 |
|
MD5 | 7490c48e692b328e043d53fa15339844 |
|
BLAKE2b-256 | a5513f9025b6b3056a05437a5793468bf5847a2e218aa6907392d0b9a69e87fc |