Switch proxy/hosts to proxy/host

The proxy only supports a single host per app for nowm so make the
config match that.
This commit is contained in:
Donal McBreen
2024-09-16 20:45:09 +01:00
parent 1f721739d6
commit 267b526438
4 changed files with 7 additions and 9 deletions

View File

@@ -7,16 +7,14 @@
# run on the same proxy. # run on the same proxy.
proxy: proxy:
# Hosts # Host
# #
# These are the hosts that will be used to serve the app. If you deploy more # The hosts that will be used to serve the app. The proxy will only route requests
# than one application to a single host, the proxy will route requests based # to this host to your app.
# these hosts
# #
# If no hosts are set, then all requests will be forwarded, except for matching # If no hosts are set, then all requests will be forwarded, except for matching
# requests for other apps that do have a host set. # requests for other apps that do have a host set.
hosts: host: foo.example.com
- foo.example.com
# App port # App port
# #

View File

@@ -37,7 +37,7 @@ class Kamal::Configuration::Proxy
def deploy_options def deploy_options
{ {
host: proxy_config.fetch("hosts", []).first, host: proxy_config["host"],
tls: proxy_config["ssl"], tls: proxy_config["ssl"],
"deploy-timeout": proxy_config["deploy_timeout"], "deploy-timeout": proxy_config["deploy_timeout"],
"drain-timeout": proxy_config["drain_timeout"], "drain-timeout": proxy_config["drain_timeout"],

View File

@@ -2,7 +2,7 @@ class Kamal::Configuration::Validator::Proxy < Kamal::Configuration::Validator
def validate! def validate!
super super
if config["hosts"].blank? && config["ssl"] if config["host"].blank? && config["ssl"]
error "Must set a host to enable automatic SSL" error "Must set a host to enable automatic SSL"
end end
end end

View File

@@ -9,7 +9,7 @@ class ConfigurationEnvTest < ActiveSupport::TestCase
end end
test "ssl with host" do test "ssl with host" do
@deploy[:proxy] = { "ssl" => true, "hosts" => [ "example.com" ] } @deploy[:proxy] = { "ssl" => true, "host" => "example.com" }
assert_equal true, config.proxy.ssl? assert_equal true, config.proxy.ssl?
end end