Skip to main content

Cloudflare proxy support for flask application

Project description

Cloudflare proxy support for flask application.

It gets client ip from cloudflare headers and can allow request from cloudflare ips only. If you are behind a proxy remember to use werkzeug.middleware.proxy_fix.ProxyFix, alternative you can override CloudflareRemote.get_remote() in order to fetch the correct client ip for example via HTTP_X_FORWARDED_FOR.

Quickstart

Install flask_cloudflare_remote using pip:

$ pip install Flask-CloudflareRemote

Example usage

import flask
from flask_cloudflare_remote import CloudflareRemote


app = Flask(__name__)
cf = CloudflareRemote()
cf.init_app(app)

Configuration

  1. CF_DOMAIN: (default: ‘www.cloudflare.com’)

  2. CF_REQ_TIMEOUT: (default: 10)

  3. CF_IPs: (default: None) list of allowed cloudflare ips

  4. CF_IP4_URI: (default: ‘/ips-v4’) ipv4 list uri

  5. CF_IP6_URI: (default: ‘/ips-v6’) ipv6 list uri

  6. CF_IPv6_ENABLED: (default: False) enable ipv6

  7. CF_STRICT_ACCESS: (default: True) return forbidden if remote ip is not in allowed list

  8. CF_OVERRIDE_REMOTE: (default: True) override flask REMOTE_ADDR from request

  9. CF_HDR_CLIENT_IP: (default: ‘CF-Connecting-IP’) header key used for client ip

License MIT

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

Flask-CloudflareRemote-1.1.1.tar.gz (3.7 kB view details)

Uploaded Source

File details

Details for the file Flask-CloudflareRemote-1.1.1.tar.gz.

File metadata

  • Download URL: Flask-CloudflareRemote-1.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.7

File hashes

Hashes for Flask-CloudflareRemote-1.1.1.tar.gz
Algorithm Hash digest
SHA256 bfaa651149c5bf44a6b4d1b977e6432fd060a1982c55d70555cc89e244c19a94
MD5 f3980a9f27c876ecb380412bc69e3e3e
BLAKE2b-256 b8f2a987add0b66dbb7b55b25d991eb2599f80f032a93763717b6fe93057657f

See more details on using hashes here.

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