basecamp / kamal

Deploy web apps anywhere.
https://kamal-deploy.org
MIT License
10.6k stars 408 forks source link

host must be set when using TLS #1037

Open bamnet opened 1 day ago

bamnet commented 1 day ago

Trying to upgrade from Kamal 2.0.0 to 2.1.0 I'm getting an error running kamal proxy reboot:

docker stdout: Nothing written
docker stderr: Error: host must be set when using TLS

SSL is terminated upstream of Kamal, so my config looks like:

# Enable SSL auto certification via Let's Encrypt (and allow for multiple apps on one server).
# Set ssl: false if using something like Cloudflare to terminate SSL (but keep host!).
proxy:
  ssl: false
  # host: app.example.com
  app_port: 3000  # https://github.com/basecamp/kamal/issues/987

Is host required even when the proxy isn't terminating SSL? It wasn't required in 2.0.0 at least.

I noticed that 2.1.0 changed the docker command adding --tls="false" which trips kamal-proxy's cmd.Flags().Changed("tls") validation here.

My limited understanding is that pflag's Changed() fires when the flag is set regardless of its value. This should probably be fixed over in kamal-proxy, but I'm opening it here in case my diagnosis is wrong.

# docker exec kamal-proxy kamal-proxy deploy app-web --target="6a37c269ff02:3000" --tls=false --deploy-timeout="30s" --drain-timeout="30s" --buffer
-requests --buffer-responses --log-request-header="Cache-Control" --log-request-header="Last-Modified" --log-request-header="User-Agent"
Error: host must be set when using TLS

vs

# docker exec kamal-proxy kamal-proxy deploy app-web --target="6a37c269ff02:3000" --deploy-timeout="30s" --drain-timeout="30s" --buffer-requests --
buffer-responses --log-request-header="Cache-Control" --log-request-header="Last-Modified" --log-request-header="User-Agent"

(no error)

brendonrogers commented 4 hours ago

This tripped me up too. # Set ssl: false if using something like Cloudflare to terminate SSL (but keep host!). - that could be interpreted as saying host is mandatory.