basecamp / kamal-proxy

Lightweight proxy server for Kamal
https://kamal-deploy.org/
MIT License
31 stars 1 forks source link

Multiple hosts per service #14

Open kevinmcconnell opened 2 days ago

kevinmcconnell commented 2 days ago

We should allow multiple hosts to map to a single service. For example:

kamal-proxy deploy myapp --target=web-1:3000 --host=app.example.com,api.example.com

This needs to be supported for the routing, and for the auto-TLS support. For the former, we can restructure the service map into two collections: the "main" service map, mapping name->service, and a "routing" map, mapping hostname->service.

For the latter, we'll include all the hostnames in the certificate management for that service.

nickpoorman commented 1 day ago

Not sure if we can yet do the following. Maybe with multiple instances of kaml-proxy pointing to the same service?

Preferably, each host would be able to acquire an ssl cert for it's domain (and not just wildcard certs for subdomains). For example:

kamal-proxy deploy myapp --target=web-1:3000 --hosts="example.com,foo.com" --tls
  1. example.com should route to web-1:3000 with a valid example.com cert.
  2. foo.com should route to web-1:3000 with a valid foo.com cert.
kevinmcconnell commented 1 day ago

@nickpoorman That's what this feature will allow, yes! (Sorry, I see now my example command in the description was wrong before, which made this quite confusing! Fixed now. Thanks for drawing attention to that.)

This will still be using a single instance of kamal-proxy, but it gives it the ability to associate multiple hosts (and their certs) with a single service & target, exactly as you've described there.

This feature is still in progress, but I should have something ready to try soon.