diff --git a/lib/kamal/commands/proxy.rb b/lib/kamal/commands/proxy.rb index 89808d72..9ae029f7 100644 --- a/lib/kamal/commands/proxy.rb +++ b/lib/kamal/commands/proxy.rb @@ -34,7 +34,6 @@ class Kamal::Commands::Proxy < Kamal::Commands::Base end def deploy(service, target:) - optionize({ target: target }) docker :exec, container_name, "kamal-proxy", :deploy, service, *optionize({ target: target }), *proxy_config.deploy_command_args end diff --git a/lib/kamal/configuration/docs/proxy.yml b/lib/kamal/configuration/docs/proxy.yml index db5b9674..8d5b201f 100644 --- a/lib/kamal/configuration/docs/proxy.yml +++ b/lib/kamal/configuration/docs/proxy.yml @@ -93,6 +93,19 @@ proxy: max_response_body: 0 memory: 2_000_000 + # Logging + # + # Configure request logging for the proxy + # You can specify request and response headers to log. + # By default, Cache-Control and Last-Modified request headers are logged + logging: + request_headers: + - Cache-Control + - X-Forwarded-Proto + response_headers: + - X-Request-ID + - X-Request-Start + # Forward headers # # Whether to forward the X-Forwarded-For and X-Forwarded-Proto headers (defaults to false) diff --git a/lib/kamal/configuration/proxy.rb b/lib/kamal/configuration/proxy.rb index ee0321d4..84a343b8 100644 --- a/lib/kamal/configuration/proxy.rb +++ b/lib/kamal/configuration/proxy.rb @@ -4,6 +4,7 @@ class Kamal::Configuration::Proxy DEFAULT_HTTP_PORT = 80 DEFAULT_HTTPS_PORT = 443 DEFAULT_IMAGE = "basecamp/kamal-proxy:latest" + DEFAULT_LOG_REQUEST_HEADERS = [ "Cache-Control", "Last-Modified" ] delegate :argumentize, :optionize, to: Kamal::Utils @@ -50,7 +51,9 @@ class Kamal::Configuration::Proxy "buffer-memory": proxy_config.dig("buffer", "memory"), "max-request-body": proxy_config.dig("buffer", "max_request_body"), "max-response-body": proxy_config.dig("buffer", "max_response_body"), - "forward-headers": proxy_config.dig("forward_headers") + "forward-headers": proxy_config.dig("forward_headers"), + "log-request-header": proxy_config.dig("logging", "request_headers") || DEFAULT_LOG_REQUEST_HEADERS, + "log-response-header": proxy_config.dig("logging", "response_headers") }.compact end