Caddy: Difference between revisions
imported>Malteneuss m Fix table layout |
imported>Malteneuss Simplify installation example |
||
Line 1: | Line 1: | ||
[https://caddyserver.com/ Caddy] is | [https://caddyserver.com/ Caddy] is an efficient, HTTP/2 capable web server that can serve static and dynamic web pages. | ||
It can also be a reverse proxy to serve multiple web services under one server. Its main features are its simple config setup and automatic HTTPS: It will automatically request and renew a LetsEncrypt certificate so that users of your service get a Browser-trusted and secure connection. | |||
== Installation == | == Installation == | ||
To try out Caddy add the following minimal example to your NixOS module: | |||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
services.caddy = { | services.caddy = { | ||
enable = true; | enable = true; | ||
extraConfig = '' | virtualHosts."localhost:80".extraConfig = '' | ||
http://localhost { | respond "Hello, world!" | ||
''; | |||
}; | |||
</syntaxhighlight> | |||
The snippet above will run Caddy on http://localhost and respond with a dummy text "Hello world!". | |||
A similar example with serving a dummy "http://localhost/example.html" page is: | |||
<syntaxhighlight lang="nix"> | |||
services.caddy = { | |||
enable = true; | |||
virtualHosts."localhost".extraConfig = '' | |||
encode gzip | |||
file_server | |||
root * ${ | |||
pkgs.runCommand "testdir" {} '' | |||
mkdir "$out" | |||
echo hello world > "$out/example.html" | |||
'' | |||
} | } | ||
''; | ''; | ||
}; | }; | ||
</syntaxhighlight> | </syntaxhighlight> | ||