path-based proxy
Kamal-proxy now supports path-based proxying (see commit https://github.com/basecamp/kamal-proxy/commit/dd1adc7cee4241054f4f086af5471cb49d905d0e).
I’m wondering when this feature will be available in Kamal?
Currently, when I set a path-prefix for a proxy, I get the following error:
ERROR (Kamal::ConfigurationError): proxy: unknown key: path-prefix
I'm really looking forward to it
Related to https://github.com/basecamp/kamal-proxy/issues/48
@shiny @ACPK Is there any update on this?
This seems like a required feature
without this, multi container apps, e.g. api + bff, become annoying to setup, because as far as I can see, this would require deploying your own nginx/caddy as the service, and then your actual applications as "accessories", which dont have the benefits (rolling updates, etc) of services
Workaround: As long as path-prefix isn't supported natively in kamal as proxy option (it seems that 2.6.0 doesn't support it yet), you can just workaround this by using a post-deploy hook that executes another kamal-proxy deploy with the path-prefix option. It could look like that (kamal-proxy >=0.9.0 required):
.kamal/hooks/post-deploy
#!/usr/bin/env bash
set -euo pipefail
# Get the container hash for the running application
CONTAINER_HASH=$(ssh my-server-01 "docker ps --filter name=myapp --format '{{.ID}}'")
# Deploy new route with container hash
ssh my-server-01 "docker exec kamal-proxy /usr/local/bin/kamal-proxy deploy myapp \
--target ${CONTAINER_HASH}:3000 \
--host myapp.dev \
--health-check-path=/ \
--path-prefix=/app"
@brgmn @shainegordon
I’ve opened a pull request that adds support for this feature: #1551. It includes notes on how to use it before it’s merged into main.
@ACPK Thanks for your PR! Looks good and I'm looking forward to it!
For other people using my post-deploy workaround - you can't use the same host for multiple deployments (kamal proxy fails with a resource error then). So I use a fake host for the second (subpath) deployment like "myapp-fake.dev" and it get's replaced by the post-deploy hook (same host but with new path-prefix option set).
I’ve opened a pull request that adds support for this feature: #1551. It includes notes on how to use it before it’s merged into main.
awesome
Will this work with ssl: false in both services?
e.g we deploy to AWS EC2, and use an ALB and Cloudfront, so we don't want/need kamal to manage SSL certificates
@shainegordon Yes, the app using the path based prefix relies on the other app for whether ssl is used.
How does PR https://github.com/basecamp/kamal/pull/1551 get merged and released?
Seems like a very safe change, that will enable a lot more Kamal adoption. We've got at least 3 stacks that I want to migrate
I suppose for now I can follow your testing instructions, and build a temp Gemfile in our CI/CD pipeline (I'm not actually a ruby developer, just find this tool very appealing)
Closed by https://github.com/basecamp/kamal/pull/1551