Английская Википедия:Caddy (web server)

Материал из Онлайн справочника
Перейти к навигацииПерейти к поиску

Шаблон:Short description Шаблон:Multiple issues Шаблон:Infobox software Caddy is an extensible, cross-platform, open-source web server written in Go.

The name "Caddy" refers both to a helper for tedious tasks, and a way to organize multiple parts into a simplified system.[1] At its core, Caddy is an extensible platform for deploying long-running services ("apps") using a single, unified configuration that can be updated on-line with a REST API.[2] Official Caddy distributions ship with a set of standard modules which include HTTP server, TLS automation, and PKI apps.[3] It is best known for its automatic HTTPS features.[4][5]

Architecture

Caddy is organized into three main components: a command, the core library, and configuration modules.[6] The command is the extensible interface by which the program is executed; it can also load configuration files, run common modes, manage installed plugins, and offer relevant utility functions. The core library has APIs for loading, unloading, and managing configuration; but it does nothing particularly useful on its own. Most of Caddy's functionality is provided by modules, which are plugins that extend Caddy's configuration structure; for example, the HTTP server is a module.[7] Caddy modules implement various long-running services, web standards, and other useful features.

Caddy's input is a JSON configuration document[8] which is received through an open socket via a RESTful HTTP API.[9][4] In the absence of an HTTP client, Caddy's command-line interface can be used to load configuration files.[10] Config adapters may be used to convert other configuration formats to JSON. Existing adapters include the Caddyfile, which has first-class support in the command line; and YAML, TOML, Nginx, and several other formats.[11][4]

When a configuration is received through its administration socket, Caddy decodes the configuration for all the specified modules, and starts running all the app modules.[4] When the app modules are being provisioned, they themselves may load and provision modules that they use. For example, the HTTP server is an app module which uses HTTP handler modules to handle HTTP requests; these handlers might use yet other modules to implement their functionality, and so on.[12] All these modules are provisioned during the config load phase.[6]

Plugins are installed by statically compiling them directly into the Caddy binary.[1][4] Without plugins, Caddy's native configuration structure only has some basic options for administration and logging.[8] All other functionality must be provided by app modules. Official Caddy distributions ship with dozens of standard modules;[3] others can be added from the project's website,[13] using the xcaddy command line tool, or by manually compiling a custom build.[14]

Miek Gieben forked Caddy to use as the core of CoreDNS, now a project of the Cloud Native Computing Foundation, as he appreciated its overall architecture and simplicity of its configuration.[15]

HTTP server

The HTTP server is an app module that comes standard with official Caddy distributions.[7] It is primarily used as a static file server[16] and load-balancing reverse proxy.[17] While the basis of Caddy's HTTP features use the implementation found in Go's standard library,[18] a variety enhancements and customizations are available as middleware and exposed through configuration parameters:[4]

By default, TLS is used automatically if any routes have a non-empty host matcher.[19] These are assumed to be site names or IP addresses that Caddy is serving, so Caddy will automatically procure and renew certificates for the configured hostnames and IP addresses. When automatic HTTPS is activated in this manner, Caddy will also redirect HTTP requests to their equivalent HTTPS location.

Development

Caddy version 2 was released on May 5, 2020.[5] Reviewers say that it still has a simpler configuration file syntax than the Apache Web Server, although version 2's configuration format is largely incompatible with the previous major release of Caddy.[5][20]

References

Шаблон:Reflist

External links