Return a 502 when container is down
If the app container is down or not responding then traefik will return a 404 response code. This is not ideal as it suggests a client rather than a server problem. To fix this, we'll define a catch all route that always returns a 502. This is not ideal as this route would take priority over a shorter route with priorty 1. TODO: up the priority of the app route.
This commit is contained in:
@@ -6,6 +6,14 @@ class Kamal::Commands::Traefik < Kamal::Commands::Base
|
||||
DEFAULT_ARGS = {
|
||||
'log.level' => 'DEBUG'
|
||||
}
|
||||
DEFAULT_LABELS = {
|
||||
# These ensure we serve a 502 rather than a 404 if no containers are available
|
||||
"traefik.http.routers.catchall.entryPoints" => "http",
|
||||
"traefik.http.routers.catchall.rule" => "PathPrefix(`/`)",
|
||||
"traefik.http.routers.catchall.service" => "unavailable",
|
||||
"traefik.http.routers.catchall.priority" => 1,
|
||||
"traefik.http.services.unavailable.loadbalancer.server.port" => "0"
|
||||
}
|
||||
|
||||
def run
|
||||
docker :run, "--name traefik",
|
||||
@@ -97,7 +105,7 @@ class Kamal::Commands::Traefik < Kamal::Commands::Base
|
||||
end
|
||||
|
||||
def labels
|
||||
config.traefik["labels"] || []
|
||||
DEFAULT_LABELS.merge(config.traefik["labels"] || {})
|
||||
end
|
||||
|
||||
def image
|
||||
|
||||
Reference in New Issue
Block a user