Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/kamal/configuration/docs/proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,16 @@ proxy:
# the deploy timeout, with a 5-second timeout for each request.
#
# Once the app is up, the proxy will stop hitting the healthcheck endpoint.
#
# The `host` option allows setting a custom Host header for health check requests.
# This is useful when your application validates the Host header (e.g., Django's
# ALLOWED_HOSTS, Rails host authorization). Without this, health checks using
# internal IPs may be rejected even when the application is healthy.
healthcheck:
interval: 3
path: /health
timeout: 3
host: example.com

# Buffering
#
Expand Down
1 change: 1 addition & 0 deletions lib/kamal/configuration/proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def deploy_options
"health-check-interval": seconds_duration(proxy_config.dig("healthcheck", "interval")),
"health-check-timeout": seconds_duration(proxy_config.dig("healthcheck", "timeout")),
"health-check-path": proxy_config.dig("healthcheck", "path"),
"health-check-host": proxy_config.dig("healthcheck", "host"),
"target-timeout": seconds_duration(proxy_config["response_timeout"]),
"buffer-requests": proxy_config.fetch("buffering", { "requests": true }).fetch("requests", true),
"buffer-responses": proxy_config.fetch("buffering", { "responses": true }).fetch("responses", true),
Expand Down
29 changes: 29 additions & 0 deletions test/configuration/proxy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,35 @@ class ConfigurationProxyTest < ActiveSupport::TestCase
end
end

test "health check host in deploy options" do
@deploy[:proxy] = {
"host" => "example.com",
"healthcheck" => {
"path" => "/up",
"host" => "example.com"
}
}

proxy = config.proxy
options = proxy.deploy_options
assert_equal "example.com", options[:"health-check-host"]
assert_equal "/up", options[:"health-check-path"]
end

test "health check without custom host" do
@deploy[:proxy] = {
"host" => "example.com",
"healthcheck" => {
"path" => "/up"
}
}

proxy = config.proxy
options = proxy.deploy_options
assert_nil options[:"health-check-host"]
assert_equal "/up", options[:"health-check-path"]
end

private
def config
Kamal::Configuration.new(@deploy)
Expand Down