{"id":15988483,"url":"https://github.com/insertish/caddy","last_synced_at":"2026-04-30T10:31:28.689Z","repository":{"id":110113939,"uuid":"504628194","full_name":"insertish/caddy","owner":"insertish","description":"Deploy Caddy using Docker.","archived":false,"fork":false,"pushed_at":"2022-07-04T13:21:34.000Z","size":5,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-10T07:11:39.994Z","etag":null,"topics":["caddy2","caddyserver","docker"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/insertish.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-06-17T17:59:48.000Z","updated_at":"2024-02-13T16:23:38.000Z","dependencies_parsed_at":null,"dependency_job_id":"accbb908-7ac6-49bb-89cc-7ae77bbc4e01","html_url":"https://github.com/insertish/caddy","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"d3f5b6073d23e6d3c6221c0e9c386e77b4416fb9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insertish%2Fcaddy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insertish%2Fcaddy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insertish%2Fcaddy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/insertish%2Fcaddy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/insertish","download_url":"https://codeload.github.com/insertish/caddy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247256782,"owners_count":20909357,"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":["caddy2","caddyserver","docker"],"created_at":"2024-10-08T04:04:29.705Z","updated_at":"2026-04-30T10:31:28.652Z","avatar_url":"https://github.com/insertish.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Caddy in Docker\r\n\r\nThis is my one-stop shop for configuring and running Caddy with Docker including setting up plugins and providing a reference on how to do common configurations.\r\n\r\n## Deploy Caddy\r\n\r\nGet started by cloning the repository and pulling up the service:\r\n\r\n```sh\r\ngit clone https://github.com/insertish/caddy\r\ncd caddy\r\ncp Caddyfile.example Caddyfile\r\ndocker-compose up -d\r\n```\r\n\r\nCaddy will bind to http://localhost:80 and you can now configure it as usual.\r\n\r\n## Working with Caddy\r\n\r\nThere are several scripts available to make your life easier:\r\n- `reload.sh`: apply an updated Caddyfile to the running Caddy server\r\n- `validate.sh`: ensure the provided configuration is valid\r\n- `fmt.sh`: format the provided Caddyfile\r\n\r\n## Using Plugins\r\n\r\nTo start using plugins, copy the example Dockerfile:\r\n\r\n```sh\r\ncp Dockerfile.example Dockerfile\r\n```\r\n\r\nAnd configure `docker-compose.override.yml` to build it:\r\n\r\n```yml\r\nversion: \"3\"\r\n\r\nservices:\r\n  caddy:\r\n    build: .\r\n```\r\n\r\n## Writing Caddyfile\r\n\r\nBelow are a bunch of useful snippets for common web server configurations which I use really frequently.\r\n\r\nYou may also want to refer to the [full directives documentation from Caddy](https://caddyserver.com/docs/caddyfile/directives).\r\n\r\n### Reverse Proxy\r\n\r\nSetting up a reverse proxy takes up a single line:\r\n\r\n```Caddyfile\r\na.test {\r\n  reverse_proxy 127.0.0.1:5000\r\n}\r\n```\r\n\r\nYou can also do stuff like send headers up to the upstream service along with other configuration, refer to [reverse_proxy](https://caddyserver.com/docs/caddyfile/directives/reverse_proxy).\r\n\r\n### Upgrade WebSocket\r\n\r\nThe following is sufficient to properly handle upgrading WebSockets:\r\n\r\n```Caddyfile\r\n@upgrade {\r\n  path /\r\n  header Connection *Upgrade*\r\n  header Upgrade websocket\r\n}\r\n\r\nreverse_proxy @upgrade 127.0.0.1:10540\r\n```\r\n\r\n### Wildcard Domains\r\n\r\nRefer to [tls](https://caddyserver.com/docs/caddyfile/directives/tls) on how to configure specific DNS providers.\r\n\r\n```Caddyfile\r\n:80 {\r\n\trespond \"Hello, World!\"\r\n}\r\n\r\n*.test {\r\n  tls {\r\n    dns \u003cprovider\u003e \u003ctoken\u003e\r\n  }\r\n\r\n\t@a host a.test\r\n\thandle @a {\r\n\t\trespond \"Subdomain a.test\"\r\n\t}\r\n\r\n\t@b host b.test\r\n\thandle @b {\r\n\t\trespond \"Subdomain b.test\"\r\n\t}\r\n\r\n\thandle {\r\n\t\trespond \"Default handler for *.test\"\r\n\t}\r\n}\r\n```\r\n\r\n### Logging\r\n\r\nBelow is a sample logger configuration which writes to the data directory.\r\n\r\n```Caddyfile\r\n{\r\n  log {\r\n    output file /data/access.log {\r\n      roll_size 1GiB\r\n    }\r\n\r\n    format json\r\n    level debug\r\n  }\r\n}\r\n```\r\n\r\nNow you can run `tail -f data/access.log` to read from it live.\r\n\r\n### Strip Prefix on Route\r\n\r\nA common pattern is to handle a route and strip the path prefix, you can combine multiple lines into one as such:\r\n\r\n```Caddyfile\r\nhandle_path /prefix/* {\r\n  [...]\r\n}\r\n```\r\n\r\nWhen the request is being handled, `/prefix` is ignored, so you can now pass this through to your upstream service for example. See documentation for [handle_path](https://caddyserver.com/docs/caddyfile/directives/handle_path) and [uri for strip_prefix](https://caddyserver.com/docs/caddyfile/directives/uri).\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsertish%2Fcaddy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finsertish%2Fcaddy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finsertish%2Fcaddy/lists"}