1. Caddy version (caddy version
):
Caddy 2.0.0
2. How I run Caddy:
Pre-built digital ocean droplet
a. System environment:
Ubuntu 18.04
b. Command:
systemctl start caddy
c. Service/unit/compose file:
n/a
d. My complete Caddyfile or JSON config:
Pretty straightforward reverse proxy for multiple custom domains:
{
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [":443"],
"routes": [
{
"handle": [
{
"handler": "subroute",
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"Host": ["{http.reverse_proxy.upstream.host}"],
"X-Forwarded-Host": ["{http.request.host}"]
}
}
},
"transport": {
"protocol": "http",
"tls": {}
},
"upstreams": [
{
"dial": "notion2site-renderer.onrender.com:443"
}
]
}
]
}
]
}
],
"match": [
{
"host": [
"masterbranch.dev",
"lownocode.dev",
"demo.notion2site.com",
"saas-journey.com",
"test.saas-journey.com",
"test2.saas-journey.com"
]
}
],
"terminal": true
}
]
}
}
}
}
}
3. The problem I’m having:
I have a few general questions around production concerns for this type of reverse proxy use case.
My customers point their custom domains to my caddy server’s static IP address on Digital Ocean, and caddy reverse proxies this traffic to an upstream Next.js webserver (currently hosted on render.com) to render their website’s content dependent on the original origin’s Host
header.
Everything is working great, and I have to say that Caddy is amazing and I’ll definitely be using it for multiple projects in the future.
A few questions I have:
-
Is there a simple way to place a CDN in front of this caddy server? It would have to have a static IP address so my customers can use DNS A records to set up their domain’s config.
-
If the CDN in front of caddy isn’t easily doable, I could use a CDN in-between Caddy and my upstream Next.js server. My main goal is to enable aggressive caching of the reverse proxied responses. Any advice on approaches to this with caddy?
Ideally the solution would use an edge CDN for caching but if all requests have to go through the Caddy server, then this negates the benefits of an edge CDN like the ones provided by Cloudflare or Vercel…
-
Are there any resources that could give me an idea of how much traffic this single Caddy server can handle by just scaling its resources vertically? I’m not sure how comfortable I am delegating this type of platform’s core architecture to a single caddy server, but I remember reading somewhere on these forums that it scales surprisingly well – I’d just love some data or live production examples to back that up.
-
With some trial and error, I was able to get this use case working pretty easily – kudos on the docs The one area that I couldn’t get working easily was logging which is especially useful during debugging. Having some examples of how to configure the logging in Caddy v2 for the simple 95% use case of logging during debugging without all the bells & whistles would be super helpful.
Thank you for your time.