Hello! I have a website builder application. Our customers can build their websites using our application. We provide a subdomain each site like 21fsdf3424.mysaasapp.com. Our customers will use their own subdomains or apex domains. Caddy seems like a good solution for this. The on-demand tls and reverse_proxy features are very nice. Let’s say we have a key value store like Redis. Example:
How can I dynamically proxy them? The ask option in on_demand_tls doesn’t exactly work for this.
You’ll still need to use ask for TLS automation. The ask endpoint is only called when Caddy needs to decide whether it should have a certificate issued. That means it’ll only happen once every couple months for each domain that is known, i.e. initially for issuance, and then for renewals after that. For domains that you reject in the ask, they’ll call your ask endpoint every time. But that’s fine as long as you make sure the ask endpoint is very fast with an O(1) lookup.
For proxying, you can write your own dynamic upstreams provider module to do a lookup in your Redis DB for the upstream address to use based on the incoming hostname.