{"id":15567690,"url":"https://github.com/circa10a/caddy-geofence","last_synced_at":"2025-10-02T23:34:46.088Z","repository":{"id":57636731,"uuid":"428110866","full_name":"circa10a/caddy-geofence","owner":"circa10a","description":"A caddy module for IP geofencing your caddy web server using ipbase.com","archived":false,"fork":false,"pushed_at":"2024-07-13T18:55:12.000Z","size":370,"stargazers_count":17,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-10T22:44:20.250Z","etag":null,"topics":["caddy","caddy-module","caddy-plugin","caddyserver","geofence","golang","hacktoberfest","redis","webserver"],"latest_commit_sha":null,"homepage":"","language":"Go","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/circa10a.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-15T03:29:57.000Z","updated_at":"2024-11-21T20:42:19.000Z","dependencies_parsed_at":"2024-06-20T01:45:30.129Z","dependency_job_id":"bdec16db-189a-423a-818a-0280451ce716","html_url":"https://github.com/circa10a/caddy-geofence","commit_stats":{"total_commits":25,"total_committers":2,"mean_commits":12.5,"dds":"0.040000000000000036","last_synced_commit":"02ba08ad167bd79b1390f69b3f1ececfd483adea"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circa10a%2Fcaddy-geofence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circa10a%2Fcaddy-geofence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circa10a%2Fcaddy-geofence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circa10a%2Fcaddy-geofence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/circa10a","download_url":"https://codeload.github.com/circa10a/caddy-geofence/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235049009,"owners_count":18927715,"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":["caddy","caddy-module","caddy-plugin","caddyserver","geofence","golang","hacktoberfest","redis","webserver"],"created_at":"2024-10-02T17:12:24.174Z","updated_at":"2025-10-02T23:34:40.790Z","avatar_url":"https://github.com/circa10a.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# caddy-geofence\n\nA caddy module for IP geofencing your caddy web server using https://ipbase.com/\n\n![Build Status](https://github.com/circa10a/caddy-geofence/workflows/deploy/badge.svg)\n[![Go Report Card](https://goreportcard.com/badge/github.com/circa10a/caddy-geofence)](https://goreportcard.com/report/github.com/circa10a/caddy-geofence)\n![GitHub release (latest by date)](https://img.shields.io/github/v/release/circa10a/caddy-geofence?style=plastic)\n![Docker Pulls](https://img.shields.io/docker/pulls/circa10a/caddy-geofence?style=plastic)\n\n![alt text](https://user-images.githubusercontent.com/1128849/36338535-05fb646a-136f-11e8-987b-e6901e717d5a.png)\n\n- [caddy-geofence](#caddy-geofence)\n  - [Usage](#usage)\n    - [Build with caddy](#build-with-caddy)\n    - [Docker](#docker)\n  - [Caddyfile example](#caddyfile-example)\n  - [Development](#development)\n    - [Run](#run)\n    - [Build](#build)\n\n## Usage\n\n1. For an IP that is not within the geofence, `403` will be returned on the matching route.\n2. An API token from [ipbase.com](https://ipbase.com/) is **required** to run this module.\n\n## Caching\n\nThis module by default will use a configurable in-memory cache, should you need an external/persistent cache, the module supports [redis](https://redis.io/). See the caddyfile exmaple below for how to enable.\n\n\u003e Free tier includes 150 requests per month\n\n### Build with caddy\n\n```shell\n# build module with caddy\nxcaddy build --with github.com/circa10a/caddy-geofence\n```\n\n### Docker\n\n```shell\ndocker run --net host -v /your/Caddyfile:/etc/caddy/Caddyfile -e IPBASE_API_TOKEN -p 80:80 -p 443:443 circa10a/caddy-geofence\n```\n\n## Caddyfile example\n\n```\n{\n\tdebug\n\torder geofence before respond\n}\n\n:80\n\nroute /* {\n\tgeofence {\n\t\t# cache_ttl is the duration to store ip addresses and if they are within proximity or not to increase performance\n\t\t# Cache for 7 days, valid time units are \"ms\", \"s\", \"m\", \"h\"\n\t\t# Not specifying a TTL sets no expiration on cached items and will live until restart\n\t\tcache_ttl 168h\n\n\t\t# ipbase.com API token, this example reads from an environment variable\n\t\tipbase_api_token {$IPBASE_API_TOKEN}\n\n\t\t# radius is the distance of the geofence in kilometers\n\t\t# If not supplied, will default to 0.0 kilometers\n\t\t# 1.0 =\u003e 1.0 kilometers\n\t\tradius 1.0\n\n\t\t# allow_private_ip_addresses is a boolean for whether or not to allow private ip ranges\n\t\t# such as 192.X, 172.X, 10.X, [::1] (localhost)\n\t\t# false by default\n\t\t# Some cellular networks doing NATing with 172.X addresses, in which case, you may not want to allow\n\t\tallow_private_ip_addresses true\n\n\t\t# allowlist is a list of IP addresses that will not be checked for proximity and will be allowed to access the server\n\t\tallowlist 206.189.205.251 206.189.205.252\n\n\t\t# status_code is the HTTP response code that is returned if IP address is not within proximity. Default is 403\n\t\tstatus_code 403\n\n\t\t# redis_enabled disables the in-memory cache and will connect to a remote redis instance\n\t\t# default is false\n\t\tredis_enabled true\n\t\t# the \u003chost\u003e:\u003cport\u003e of the remote redis instance\n\t\t# default is localhost:6379\n\t\tredis_addr redis:6379\n\t\t# redis_username is the username to connect to a secured redis instance\n\t\t# default is \"\"\n\t\tredis_username user\n\t\t# redis_password is the password to connect to a secured redis instance\n\t\t# default is \"\"\n\t\tredis_password password\n\t\t# redis_db is the id of the redis db to connect to to store cache ip addresses\n\t\t# default is 0\n\t\tredis_db 0\n\t}\n}\n\nlog {\n\toutput stdout\n}\n```\n\n## Development\n\nRequires [xcaddy](https://caddyserver.com/docs/build#xcaddy) to be installed\n\n### Run\n\n```shell\nexport IPBASE_API_TOKEN=\u003ctoken\u003e\nmake run\n```\n\n### Build\n\n```shell\nmake build\n```\n\n### Run redis enabled stack\n\n```shell\nexport IPBASE_API_TOKEN=\u003ctoken\u003e\nmake redis\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcirca10a%2Fcaddy-geofence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcirca10a%2Fcaddy-geofence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcirca10a%2Fcaddy-geofence/lists"}