Do not allow both host and hosts for proxy configuration
This commit is contained in:
@@ -31,7 +31,7 @@ proxy:
|
|||||||
# Hosts
|
# Hosts
|
||||||
#
|
#
|
||||||
# The hosts that will be used to serve the app. The proxy will only route requests
|
# The hosts that will be used to serve the app. The proxy will only route requests
|
||||||
# to this host to your app.
|
# to these hosts to your app.
|
||||||
#
|
#
|
||||||
# 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 deployed on that server that do have a host set.
|
# requests for other apps deployed on that server that do have a host set.
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ class Kamal::Configuration::Validator::Proxy < Kamal::Configuration::Validator
|
|||||||
if config["host"].blank? && config["hosts"].blank? && config["ssl"]
|
if config["host"].blank? && config["hosts"].blank? && config["ssl"]
|
||||||
error "Must set a host to enable automatic SSL"
|
error "Must set a host to enable automatic SSL"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if config["host"].present? && config["hosts"].present?
|
||||||
|
error "Must use either 'host' or 'hosts', not both"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ class ConfigurationProxyTest < ActiveSupport::TestCase
|
|||||||
assert_raises(Kamal::ConfigurationError) { config.proxy.ssl? }
|
assert_raises(Kamal::ConfigurationError) { config.proxy.ssl? }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
test "ssl with both host and hosts" do
|
||||||
|
@deploy[:proxy] = { "ssl" => true, host: "example.com", hosts: [ "anotherexample.com" ] }
|
||||||
|
assert_raises(Kamal::ConfigurationError) { config.proxy.ssl? }
|
||||||
|
end
|
||||||
|
|
||||||
test "ssl false" do
|
test "ssl false" do
|
||||||
@deploy[:proxy] = { "ssl" => false }
|
@deploy[:proxy] = { "ssl" => false }
|
||||||
assert_not config.proxy.ssl?
|
assert_not config.proxy.ssl?
|
||||||
|
|||||||
Reference in New Issue
Block a user