{"id":15065515,"url":"https://github.com/circa10a/caddy-terraform-registry-cache","last_synced_at":"2026-01-05T20:06:17.661Z","repository":{"id":256868336,"uuid":"856092170","full_name":"circa10a/caddy-terraform-registry-cache","owner":"circa10a","description":"A pull-through cache for Terraform providers and modules using only Caddy","archived":false,"fork":false,"pushed_at":"2024-09-13T02:37:31.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-12T10:32:40.885Z","etag":null,"topics":["cache","hashicorp","hashicorp-terraform","proxy","reverse-proxy","terraform","webserver"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","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":"2024-09-12T01:18:17.000Z","updated_at":"2024-09-13T02:39:25.000Z","dependencies_parsed_at":"2024-09-13T14:27:26.107Z","dependency_job_id":"2aa16e4e-3df1-4854-8600-1a6f14432c0d","html_url":"https://github.com/circa10a/caddy-terraform-registry-cache","commit_stats":null,"previous_names":["circa10a/caddy-terraform-registry-cache"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circa10a%2Fcaddy-terraform-registry-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circa10a%2Fcaddy-terraform-registry-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circa10a%2Fcaddy-terraform-registry-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/circa10a%2Fcaddy-terraform-registry-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/circa10a","download_url":"https://codeload.github.com/circa10a/caddy-terraform-registry-cache/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235048983,"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":["cache","hashicorp","hashicorp-terraform","proxy","reverse-proxy","terraform","webserver"],"created_at":"2024-09-25T00:39:52.055Z","updated_at":"2025-10-02T23:34:50.655Z","avatar_url":"https://github.com/circa10a.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# caddy-terraform-registry-cache \u003cimg src=\"https://i.imgur.com/fAS7XqO.png\" height=\"5%\" width=\"5%\" align=\"left\"/\u003e\n\nA pull-through cache for Terraform providers using only Caddy. [Inspired by terrateam.io's blog post](https://terrateam.io/blog/terraform-registry-cache)\n\n![Build Status](https://github.com/circa10a/caddy-terraform-registry-cache/workflows/deploy/badge.svg)\n![Docker Pulls](https://img.shields.io/docker/pulls/circa10a/caddy-terraform-registry-cache?style=plastic)\n\n\u003cimg src=\"https://user-images.githubusercontent.com/1128849/36338535-05fb646a-136f-11e8-987b-e6901e717d5a.png\" width=\"60%\"/\u003e\n\n## Background\n\n\u003e [!CAUTION]\n\u003e If you're thinking about using this in production to save yourself from Hashicorp's occasional CDN outages. You should know that this doesn't support caching providers from GitHub, only official hashicorp namespaced providers.\n\nI was browsing reddit recently and came across this [post](https://www.reddit.com/r/Terraform/comments/u11m4u/terraform_provider_cache/?rdt=61441) that described a user reproducing a custom Go application that served as a Terraform provider proxy + cache, but reimplemented with Nginx. I thought it was a pretty cool idea and wanted to see if I could implement my own verison using my favorite web server [caddy](https://caddyserver.com/). Thus, the reason for this project.\n\n## Requirements\n\nYou'll need two domains pointed at the address that hosts this web server. They'll be referred to as `REGISTRY_SITE_ADDRESS` and `RELEASES_SITE_ADDRESS` in this README. We need two because registry.terraform.io serves JSON that references a separate URL that points to `releases.hashicorp.com` and we need SNI rules in the reverse proxy configuration to support proxying both sites. TLDR; two sites, one server.\n\n## Usage\n\nTo run `caddy-terraform-registry-cache`, you'll need two domains with DNS records for your host(s). This is required due to the use of the [ACME protocol implemented by Caddy](https://caddyserver.com/docs/automatic-https) for automatic TLS by using certificates issued by [Let's Encrypt](https://letsencrypt.org/) because Terraform/Opentofu require registries to use HTTPS. The configuration could of course be [modified to supply your own certificate and key](https://caddyserver.com/docs/caddyfile/directives/tls), but it isn't natively supported via environment variables.\n\n```console\ndocker run --rm --name caddy-terraform-registry-cache  \\\n    -e REGISTRY_SITE_ADDRESS \\\n    -e RELEASES_SITE_ADDRESS \\\n    -v ./cache:/cache \\\n    -p 443:443 \\\n    -p 80:80 \\\n    circa10a/caddy-terraform-registry-cache\n````\n\n\u003e [!IMPORTANT]\n\u003e If you made it past the red bulletin and still want to continue, you should _also_ know that if this server is restarted while Hashicorp's CDN is down, you'll receive 502's. Look it's not me, it's the implementation of caddy's [cache-handler](https://github.com/caddyserver/cache-handler)\n\n### Terraform configuration\n\nYou'll need to modify your Terraform/Opentofu source to point to the caddy reverse proxy. Yes, this does indeed mean that we're installing entirely different providers from a Terraform perspective and it is much more ideal to implement [the network mirror protocol](https://developer.hashicorp.com/terraform/internals/provider-network-mirror-protocol). I understand why Hashicorp did this since the protocol does allow for some more flexiblility for download locations.\n\nHere's how you use this proxy in Terraform:\n\n```hcl\nterraform {\n  required_providers {\n    aws = {\n      source = \"${REGISTRY_SITE_ADDRESS}/hashicorp/aws\"\n    }\n  }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcirca10a%2Fcaddy-terraform-registry-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcirca10a%2Fcaddy-terraform-registry-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcirca10a%2Fcaddy-terraform-registry-cache/lists"}