Spec-Zone.ru › Caddy

invoke

⚠️ Experimental

Invokes a named route.

This is useful when paired with HTTP handler directives that have their own in-memory state, or if they are expensive to provision on load. If you have hundreds of sites or more, invoking a named route can help reduce memory usage.

Unlike import, invoke does not support arguments, but you may use vars to define variables that can be used within the named route.

Syntax

invoke [<matcher>] <route-name>
  • <route-name> is the name of the previously defined route that should be invoked. If the route is not found, then an error will be triggered.

Examples

Defines a named route with a reverse_proxy which can be reused in multiple sites, with the same in-memory load balancing state reused for every site.

&(app-proxy) {
	reverse_proxy app-01:8080 app-02:8080 app-03:8080 {
		lb_policy least_conn
		health_uri /healthz
		health_interval 5s
	}
}# Apex domain allows accessing the app via an /app subpath
# and the main site otherwise.
example.com {
	handle_path /app* {
		invoke app-proxy
	}
	handle {
		root * /srv
		file_server
	}
}# The app is also accessible via a subdomain.
app.example.com {
	invoke app-proxy
}

© 2015-2025 Matthew Holt and The Caddy Authors
Licensed under the Apache License 2.0.
Caddy is a registered trademark of Stack Holdings GmbH.
https://caddyserver.com/docs/caddyfile/directives/invoke

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API