-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is fallback on a reverse_proxy's lb_policy being parsed properly? #6272
Comments
Ah I was able to get this to work by using the JSON format, so it seems like my suspicion was correct, caddy right now does not parse that format properly in Caddyfile properly. Here is how I got it to work: Given this starting Caddyfile: :1234 {
reverse_proxy http://app:3000 {
lb_policy header X-Upstream
}
} I adapted it to JSON with: Which resulted in this file: {
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":1234"
],
"routes": [
{
"handle": [
{
"handler": "reverse_proxy",
"load_balancing": {
"selection_policy": {
"field": "X-Upstream",
"policy": "header"
}
},
"upstreams": [
{
"dial": "app:3000"
}
]
}
]
}
]
}
}
}
}
} I then was able to add a fallback key: diff --git a/Caddyfile.json b/Caddyfile.json.after
index 66d03e3..e20aa98 100644
--- a/Caddyfile.json
+++ b/Caddyfile.json.after
@@ -14,7 +14,10 @@
"load_balancing": {
"selection_policy": {
"field": "X-Upstream",
- "policy": "header"
+ "policy": "header",
+ "fallback": {
+ "policy": "first"
+ }
}
},
"upstreams": [
and I checked and it parses & works as expected. So it seems to me the only problem is the Caddyfile format & how it parses that extra block for the fallback field. |
I can confirm it's broken on v2.7.6, but it's already been fixed on Try a build from We'll be releasing v2.8.0 soon. |
I appreciate your response here. I tried a couple of other 2.7 versions and couldn't find one that works. I'll just use the JSON version for now and wait for 2.8 to release |
We'd actually love for more people to try the beta (what is on master now is practically the beta). You can download the latest build here: https://github.com/caddyserver/caddy/actions/runs/8823591506#artifacts |
First of all, thank you so much for your work on caddy, absolutely great reverse proxy that I've been relying on for years.
When trying to do a reverse_proxy, using the sample code from the docs does not work:
Failing to start caddy with this error message:
Here is my minimal caddyfile reproduction:
It seems to me that this fallback option should work and was implemented as part of this PR: #5488
I also tried using this for the
query
lb_policy and it did not work either. Maybe this is just that the caddyfile is failing to be parsed properly?If I knew go better, I'd offer my help in fixing it. But, alas, I may never be a gopher, so I will only report it instead.
The text was updated successfully, but these errors were encountered: