{"id":15148389,"url":"https://github.com/slashtechno/cloudflare-gateway-adblocking","last_synced_at":"2025-10-24T03:31:45.148Z","repository":{"id":185372713,"uuid":"616620204","full_name":"slashtechno/cloudflare-gateway-adblocking","owner":"slashtechno","description":"Serverless ad blocking via Cloudflare Zero Trust gateway","archived":false,"fork":false,"pushed_at":"2024-05-12T21:20:50.000Z","size":175,"stargazers_count":21,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-30T22:42:49.474Z","etag":null,"topics":["adblocking","cloudflare","dns","pi-hole"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/cloudflare-gateway-adblocking/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/slashtechno.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-03-20T18:40:36.000Z","updated_at":"2024-10-14T15:21:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"4243da6d-bd7b-4d36-9f4d-e085dc63a336","html_url":"https://github.com/slashtechno/cloudflare-gateway-adblocking","commit_stats":null,"previous_names":["slashtechno/cloudflare-gateway-adblocking"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashtechno%2Fcloudflare-gateway-adblocking","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashtechno%2Fcloudflare-gateway-adblocking/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashtechno%2Fcloudflare-gateway-adblocking/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/slashtechno%2Fcloudflare-gateway-adblocking/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/slashtechno","download_url":"https://codeload.github.com/slashtechno/cloudflare-gateway-adblocking/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237910078,"owners_count":19385829,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adblocking","cloudflare","dns","pi-hole"],"created_at":"2024-09-26T13:03:28.490Z","updated_at":"2025-10-24T03:31:44.779Z","avatar_url":"https://github.com/slashtechno.png","language":"Python","funding_links":["https://github.com/sponsors/slashtechno"],"categories":[],"sub_categories":[],"readme":"# Cloudflare Gateway Adblocking  \n![PyPI](https://img.shields.io/pypi/v/cloudflare-gateway-adblocking?style=for-the-badge\u0026logo=python\u0026link=https%3A%2F%2Fpypi.org%2Fproject%2Fcloudflare-gateway-adblocking%2F)    \nServerless adblocking via Cloudflare Zero Trust Gateway  \n\n### What is this?  \nThis is a serverless adblocking solution that uses Cloudflare's Zero Trust Gateway to block ads by parsing a hosts file and creating a firewall rule to block the domains. It can be used as an alternative to Pi-Hole or other adblocking solutions.  \nThis project was heavily inspired by [this blog post](https://blog.marcolancini.it/2022/blog-serverless-ad-blocking-with-cloudflare-gateway/)  \n\n\n### Prerequisites\n* Python \u003e 3.10  \n* A Cloudflare account with Zero Trust enabled  \n* A Cloudflare API tolken with the following permissions:  \n    * Zero Trust: Edit  \n    * Account Firewall Access Rules: Edit  \n    * Access: Apps and Policies: Edit  \n* A device with the WARP client installed and configured to use a Zero Trust account  \n\n\n### Installation  \n#### From PyPi  \n`pip install cloudflare-gateway-adblocking`  \n\n\n### Usage   \n#### Setting Cloudflare credentials  \n##### Environment variables  \nThe following environment variables can be used to set the Cloudflare credentials:  \n* `CLOUDFLARE_ACCOUNT_ID`\n* `CLOUDFLARE_TOKEN`  \nThese can either be set in the environment or in a `.env` file in the current working directory.  \n#### Command line flags  \nThe following command line flags can be used to set the Cloudflare credentials:\n* Cloudflare Account ID: `--account-id` / `-a`  \n* Cloudflare Token: `--token` / `-t`  \n#### Passing blocklists  \nBlocklists can be passed to the program via the command line flag `--blocklist` / `-b`. This flag can either point to a hosts file or a directory containing hosts files. If this flag is not passed, the program will look for a file or directory named `blocklists` in the current working directory.  \n#### Passing whitelists  \nWhitelists can be passed to the program via the command line flag `--whitelist` / `-w`. This flag can either point to a hosts file or a directory containing hosts files. If this flag is not passed, then if a file or directory named `whitelists` exists in the current working directory, it will be used. Domains in this whitelist will be excluded from the blocklists.  \n#### Uploading blocklists and creating a firewall policy\nTo upload the blocklists to Cloudflare and create a firewall policy, use the `upload` subcommand.  \nFor example:  \n`cloudflare-gateway-adblocking upload`  \n#### Deleting blocklists and firewall policy  \nTo delete the blocklists from Cloudflare and delete the firewall policy, use the `delete` subcommand.  \nFor example:  \n`cloudflare-gateway-adblocking delete`  \n### Help  \nFor help, use the `--help` flag.  \n### Contributing  \n* [Sponsoring](https://github.com/sponsors/slashtechno) via GitHub\n* Contributing code via a pull request\n* Reporting encoutered issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslashtechno%2Fcloudflare-gateway-adblocking","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fslashtechno%2Fcloudflare-gateway-adblocking","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fslashtechno%2Fcloudflare-gateway-adblocking/lists"}