Caddy: Difference between revisions
→Check used ports: Replace deprecated netstat with ss |
|||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 145: | Line 145: | ||
</syntaxhighlight>This example will serve a [[uWSGI]] app, provided by a unix socket file, on the host <code>myapp.example.org</code>. | </syntaxhighlight>This example will serve a [[uWSGI]] app, provided by a unix socket file, on the host <code>myapp.example.org</code>. | ||
=== Caching === | |||
Caching can be enabled by adding the official [https://github.com/caddyserver/cache-handler cache-handler plugin]. Note that the corresponding hash and upstream version can change.<syntaxhighlight lang="nix"> | |||
services.caddy = { | |||
package = pkgs.caddy.withPlugins { | |||
plugins = [ "github.com/caddyserver/cache-handler@v0.16.0" ]; | |||
hash = "sha256-XTFwYo3o7il3UfnE2QuJM+UoGTu0Yw+8ka0p9czdgEM="; | |||
}; | |||
globalConfig = '' | |||
cache | |||
''; | |||
virtualHosts = { | |||
"example.org" = { | |||
extraConfig = '' | |||
cache | |||
reverse_proxy your-app:8080 | |||
''; | |||
}; | |||
}; | |||
</syntaxhighlight>If you need to add caching to an existing virtual host entry, which was created by a module, you can prepend it by using <code>lib.mkBefore</code><syntaxhighlight lang="nix"> | |||
services.caddy = { | |||
[...] | |||
virtualHosts."dokuwiki.example.org".extraConfig = lib.mkBefore '' | |||
cache { | |||
ttl 30m | |||
stale 1h | |||
] | |||
''; | |||
}; | |||
</syntaxhighlight>See [https://github.com/caddyserver/cache-handler upstream documentation] for further configuration options. | |||
=== Passing environment variable secrets/configuring acme_dns === | === Passing environment variable secrets/configuring acme_dns === | ||
| Line 166: | Line 198: | ||
=== Check used ports === | === Check used ports === | ||
To check if Caddy is running and listening as configured you can run <code> | To check if Caddy is running and listening as configured you can run <code>ss</code>: | ||
<syntaxhighlight lang="console"> | <syntaxhighlight lang="console"> | ||