caddyserver / caddy

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
https://caddyserver.com
Apache License 2.0
55.53k stars 3.91k forks source link

binding to an interface explicite is not possible multiple times #6321

Open Hero9909 opened 1 month ago

Hero9909 commented 1 month ago

when using the default_bind and a custom or multiple custom binds on the same address ar used caddy tries to bind 2 two or more times to the address.

using caddy v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=

setup: i have 3 services which need an upgrade from http to https, each listen on a local port now i specify with caddy 3 sections

1.example.com:443 {
  bind 10.0.0.5
  reverse_proxy to-a
}
2.example.com:443 {
  bind 10.0.1.5
  reverse_proxy to-b
}
3.example.com:443 {
  bind 10.0.0.5 10.0.1.5
  reverse_proxy to-c
}

so this does not work, even if i remove the bind of the last block.

francislavoie commented 1 month ago

The problem is that the Caddyfile adapter would need to recognize that both of those bind addresses will exist on other servers that exclusively listen to that address, then copy the routes for your 3 domain to both of those. It's not currently smart enough to do that.

Run caddy adapt -p on your Caddyfile to see what I mean, Caddy produces servers with listen addresses, and the servers must not overlap otherwise they will try to bind to the same address.

mholt commented 1 month ago

Oh... yeah, edge case. That is just a little more complicated than I wanted to do at the time. So if we're going to fix that we'll need to decide if it's worth the added complexity.