diff --git a/lib/kamal/configuration/docs/proxy.yml b/lib/kamal/configuration/docs/proxy.yml index 87e428e3c..d6bc9bce9 100644 --- a/lib/kamal/configuration/docs/proxy.yml +++ b/lib/kamal/configuration/docs/proxy.yml @@ -70,6 +70,19 @@ proxy: # HTTPS traffic), you can disable this redirect by setting `ssl_redirect: false`: ssl_redirect: false + # ACME cache path + # + # The directory where kamal-proxy stores Let's Encrypt certificates and account keys. + # The path is inside the kamal-proxy container. Use a path on a persistent volume, + # such as below `/home/kamal-proxy/.config/kamal-proxy`, so that the certificates + # are kept when the proxy restarts. + # + # If you mount a shared volume at this path, multiple kamal-proxy instances can share + # the Let's Encrypt certificates for the same domains. + # + # Defaults to the kamal-proxy certificate directory: + ssl_acme_cache_path: /home/kamal-proxy/.config/kamal-proxy/certs + # Forward headers # # Whether to forward the `X-Forwarded-For` and `X-Forwarded-Proto` headers. diff --git a/lib/kamal/configuration/proxy.rb b/lib/kamal/configuration/proxy.rb index 3f2d83fad..fb32b4157 100644 --- a/lib/kamal/configuration/proxy.rb +++ b/lib/kamal/configuration/proxy.rb @@ -73,6 +73,7 @@ def deploy_options tls: ssl? ? true : nil, "tls-certificate-path": container_tls_cert, "tls-private-key-path": container_tls_key, + "tls-acme-cache-path": proxy_config["ssl_acme_cache_path"], "deploy-timeout": seconds_duration(config.deploy_timeout), "drain-timeout": seconds_duration(config.drain_timeout), "health-check-interval": seconds_duration(proxy_config.dig("healthcheck", "interval")), diff --git a/test/configuration/proxy_test.rb b/test/configuration/proxy_test.rb index e0b328f3b..6ed82915e 100644 --- a/test/configuration/proxy_test.rb +++ b/test/configuration/proxy_test.rb @@ -81,6 +81,16 @@ class ConfigurationProxyTest < ActiveSupport::TestCase end end + test "deploy options with acme cache path" do + @deploy[:proxy] = { "ssl" => true, "host" => "example.com", "ssl_acme_cache_path" => "/home/kamal-proxy/.config/kamal-proxy/acme" } + assert_equal "/home/kamal-proxy/.config/kamal-proxy/acme", config.proxy.deploy_options[:"tls-acme-cache-path"] + end + + test "deploy options without acme cache path" do + @deploy[:proxy] = { "ssl" => true, "host" => "example.com" } + assert_not config.proxy.deploy_options.key?(:"tls-acme-cache-path") + end + test "ssl with certificate and no private key" do with_test_secrets("secrets" => "CERT_PEM=certificate") do @deploy[:proxy] = {