{"id":20536638,"url":"https://github.com/xyhhx/caddy-compose-crowdsec","last_synced_at":"2025-07-19T18:08:46.641Z","repository":{"id":241380629,"uuid":"806702906","full_name":"xyhhx/caddy-compose-crowdsec","owner":"xyhhx","description":"example of using docker compose to provision caddy with crowdsec, based on the chainguard image","archived":false,"fork":false,"pushed_at":"2024-05-27T18:30:39.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-06T03:35:43.266Z","etag":null,"topics":["caddy","caddy-security","crowdsec","docker-compose","web-security"],"latest_commit_sha":null,"homepage":"https://git.sr.ht/~xyhhx/caddy-compose-crowdsec","language":"Makefile","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xyhhx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2024-05-27T18:08:24.000Z","updated_at":"2024-05-27T18:30:42.000Z","dependencies_parsed_at":"2024-05-28T03:56:54.775Z","dependency_job_id":"2a3e2af0-85c1-4371-8f64-d6f00ca32979","html_url":"https://github.com/xyhhx/caddy-compose-crowdsec","commit_stats":null,"previous_names":["xyhhx/caddy-compose-crowdsec"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/xyhhx/caddy-compose-crowdsec","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyhhx%2Fcaddy-compose-crowdsec","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyhhx%2Fcaddy-compose-crowdsec/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyhhx%2Fcaddy-compose-crowdsec/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyhhx%2Fcaddy-compose-crowdsec/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xyhhx","download_url":"https://codeload.github.com/xyhhx/caddy-compose-crowdsec/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xyhhx%2Fcaddy-compose-crowdsec/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265982890,"owners_count":23859575,"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-security","crowdsec","docker-compose","web-security"],"created_at":"2024-11-16T00:37:22.553Z","updated_at":"2025-07-19T18:08:46.612Z","avatar_url":"https://github.com/xyhhx.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# Caddy\n\n[Caddy Website](https://caddyserver.com/) | [Caddy Documentation](https://caddyserver.com/docs)\n\nCanonical source: https://git.sr.ht/~xyhhx/caddy-compose-crowdsec\n\n[Github Mirror](https://github.com/xyhhx/caddy-compose-crowdsec) | [Codeberg Mirror](https://codeberg.org/xyhhx/caddy-compose-crowdsec)\n\n\u003c/div\u003e\n\nIt's pretty well known that security through obscurity is useless and that bots/script kiddies parse new TLS certificates to scour for juicy links; but you might not be aware of [just how actively they do that](https://honeypot.net/2024/05/16/i-am-not.html).\n\nTo mitigate this, it might be a good idea to use Crowdsec to block known bad IPs. A custom module for Caddy exists, so we can use this to do it pretty trivially from Caddy itself.\n\n## Prerequesites\n\nThis repo is designed to be used in a Linux working environment with the following dependencies installed:\n\n- [Docker](https://docker.com)\n- `make`\n\n## Usage\n\n### Administration\n\nFirst, generate a crowdsec API key:\n\n```sh\nmake crowdsec-key\n```\n\nThen run the following commands to start the Compose project\n\n```sh\nmake up\n```\n\nYou can spin down the project like so:\n\n```sh\nmake down\n```\n\nYou can destroy the project with the following command:\n\n\u003e **Important** This will remove the Docker network and wipe `./data/caddy`\n\n```sh\nmake clean\n```\n\n## Examples\n\n### Adding a simple web app\n\nLet's say your app is called `myapp` and you want to expose it via this Caddy project.\n\nLet's also assume `myapp` exposes port 8000 for its web interface.\n\n#### Configuring your app\n\nOther projects should have the following in their Compose files:\n\n\n```yml\nnetworks:\n  webproxy:\n    external: true\n```\n\nAnd, for any services you want to handle with caddy, you should name them and add the `webproxy` network to them.\n\n```yml\nservices:\n  myapp:\n    container_name: myapp\n    networks:\n      - webproxy\n```\n\n#### Configuring Caddy\n\nYou will also need to make changes to the Caddyfile:\n\n```diff\nmyapp.com {\n  route {\n    crowdsec\n    reverse_proxy myapp:8000\n  }\n  log {\n    output file /var/log/caddy/access.log\n  }\n}\n```\n\nFinally, you can run the following to restart Caddy:\n\n```sh\nmake down up\n# Or...\ndocker compose up -d --force-recreate\n```\n## Further Reading\n\n- https://github.com/hslatman/caddy-crowdsec-bouncer\n- https://www.crowdsec.net/blog/secure-docker-compose-stacks-with-crowdsec\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxyhhx%2Fcaddy-compose-crowdsec","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxyhhx%2Fcaddy-compose-crowdsec","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxyhhx%2Fcaddy-compose-crowdsec/lists"}