Class: Kamal::Configuration::Proxy
- Inherits:
-
Object
- Object
- Kamal::Configuration::Proxy
- Includes:
- Validation
- Defined in:
- lib/kamal/configuration/proxy.rb
Constant Summary collapse
- DEFAULT_LOG_REQUEST_HEADERS =
[ "Cache-Control", "Last-Modified", "User-Agent" ]
- CONTAINER_NAME =
"kamal-proxy"
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#proxy_config ⇒ Object
readonly
Returns the value of attribute proxy_config.
Instance Method Summary collapse
- #app_port ⇒ Object
- #deploy_command_args(target:) ⇒ Object
- #deploy_options ⇒ Object
- #hosts ⇒ Object
-
#initialize(config:, proxy_config:, context: "proxy") ⇒ Proxy
constructor
A new instance of Proxy.
- #merge(other) ⇒ Object
- #ssl? ⇒ Boolean
Methods included from Validation
Constructor Details
#initialize(config:, proxy_config:, context: "proxy") ⇒ Proxy
Returns a new instance of Proxy.
11 12 13 14 15 |
# File 'lib/kamal/configuration/proxy.rb', line 11 def initialize(config:, proxy_config:, context: "proxy") @config = config @proxy_config = proxy_config validate! @proxy_config, with: Kamal::Configuration::Validator::Proxy, context: context end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
9 10 11 |
# File 'lib/kamal/configuration/proxy.rb', line 9 def config @config end |
#proxy_config ⇒ Object (readonly)
Returns the value of attribute proxy_config.
9 10 11 |
# File 'lib/kamal/configuration/proxy.rb', line 9 def proxy_config @proxy_config end |
Instance Method Details
#app_port ⇒ Object
17 18 19 |
# File 'lib/kamal/configuration/proxy.rb', line 17 def app_port proxy_config.fetch("app_port", 80) end |
#deploy_command_args(target:) ⇒ Object
51 52 53 |
# File 'lib/kamal/configuration/proxy.rb', line 51 def deploy_command_args(target:) optionize ({ target: "#{target}:#{app_port}" }).merge(), with: "=" end |
#deploy_options ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/kamal/configuration/proxy.rb', line 29 def { host: hosts, tls: proxy_config["ssl"].presence, "tls-on-demand-url": proxy_config["tls_on_demand_url"], "deploy-timeout": seconds_duration(config.deploy_timeout), "drain-timeout": seconds_duration(config.drain_timeout), "health-check-interval": seconds_duration(proxy_config.dig("healthcheck", "interval")), "health-check-timeout": seconds_duration(proxy_config.dig("healthcheck", "timeout")), "health-check-path": proxy_config.dig("healthcheck", "path"), "target-timeout": seconds_duration(proxy_config["response_timeout"]), "buffer-requests": proxy_config.fetch("buffering", { "requests": true }).fetch("requests", true), "buffer-responses": proxy_config.fetch("buffering", { "responses": true }).fetch("responses", true), "buffer-memory": proxy_config.dig("buffering", "memory"), "max-request-body": proxy_config.dig("buffering", "max_request_body"), "max-response-body": proxy_config.dig("buffering", "max_response_body"), "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 |
#hosts ⇒ Object
25 26 27 |
# File 'lib/kamal/configuration/proxy.rb', line 25 def hosts proxy_config["hosts"] || proxy_config["host"]&.split(",") || [] end |
#merge(other) ⇒ Object
55 56 57 |
# File 'lib/kamal/configuration/proxy.rb', line 55 def merge(other) self.class.new config: config, proxy_config: proxy_config.deep_merge(other.proxy_config) end |
#ssl? ⇒ Boolean
21 22 23 |
# File 'lib/kamal/configuration/proxy.rb', line 21 def ssl? proxy_config.fetch("ssl", false) end |