nixos/wordpress: caddy support
This commit is contained in:
parent
29f8f30b37
commit
38431cf21c
4 changed files with 48 additions and 5 deletions
|
@ -1056,8 +1056,8 @@ Superuser created successfully.
|
|||
The wordpress module provides a new interface which allows to
|
||||
use different webservers with the new option
|
||||
<link xlink:href="options.html#opt-services.wordpress.webserver"><literal>services.wordpress.webserver</literal></link>.
|
||||
Currently <literal>httpd</literal> and
|
||||
<literal>nginx</literal> are supported. The definitions of
|
||||
Currently <literal>httpd</literal>, <literal>caddy</literal>
|
||||
and <literal>nginx</literal> are supported. The definitions of
|
||||
wordpress sites should now be set in
|
||||
<link xlink:href="options.html#opt-services.wordpress.sites"><literal>services.wordpress.sites</literal></link>.
|
||||
</para>
|
||||
|
|
|
@ -317,7 +317,7 @@ To be able to access the web UI this port needs to be opened in the firewall.
|
|||
|
||||
- The `claws-mail` package now references the new GTK+ 3 release branch, major version 4. To use the GTK+ 2 releases, one can install the `claws-mail-gtk2` package.
|
||||
|
||||
- The wordpress module provides a new interface which allows to use different webservers with the new option [`services.wordpress.webserver`](options.html#opt-services.wordpress.webserver). Currently `httpd` and `nginx` are supported. The definitions of wordpress sites should now be set in [`services.wordpress.sites`](options.html#opt-services.wordpress.sites).
|
||||
- The wordpress module provides a new interface which allows to use different webservers with the new option [`services.wordpress.webserver`](options.html#opt-services.wordpress.webserver). Currently `httpd`, `caddy` and `nginx` are supported. The definitions of wordpress sites should now be set in [`services.wordpress.sites`](options.html#opt-services.wordpress.sites).
|
||||
|
||||
Sites definitions that use the old interface are automatically migrated in the new option. This backward compatibility will be removed in 22.05.
|
||||
|
||||
|
|
|
@ -278,7 +278,7 @@ in
|
|||
};
|
||||
|
||||
options.webserver = mkOption {
|
||||
type = types.enum [ "httpd" "nginx" ];
|
||||
type = types.enum [ "httpd" "nginx" "caddy" ];
|
||||
default = "httpd";
|
||||
description = ''
|
||||
Whether to use apache2 or nginx for virtual host management.
|
||||
|
@ -458,5 +458,32 @@ in
|
|||
};
|
||||
})
|
||||
|
||||
(mkIf (cfg.webserver == "caddy") {
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
virtualHosts = mapAttrs' (hostName: cfg: (
|
||||
nameValuePair "http://${hostName}" {
|
||||
extraConfig = ''
|
||||
root * /${pkg hostName cfg}/share/wordpress
|
||||
file_server
|
||||
|
||||
php_fastcgi unix/${config.services.phpfpm.pools."wordpress-${hostName}".socket}
|
||||
|
||||
@uploads {
|
||||
path_regexp path /uploads\/(.*)\.php
|
||||
}
|
||||
rewrite @uploads /
|
||||
|
||||
@wp-admin {
|
||||
path not ^\/wp-admin/*
|
||||
}
|
||||
rewrite @wp-admin {path}/index.php?{query}
|
||||
'';
|
||||
}
|
||||
)) eachSite;
|
||||
};
|
||||
})
|
||||
|
||||
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -45,6 +45,21 @@ import ./make-test-python.nix ({ pkgs, ... }:
|
|||
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
|
||||
};
|
||||
|
||||
wp_caddy = { ... }: {
|
||||
services.wordpress.webserver = "caddy";
|
||||
services.wordpress.sites = {
|
||||
"site1.local" = {
|
||||
database.tablePrefix = "site1_";
|
||||
};
|
||||
"site2.local" = {
|
||||
database.tablePrefix = "site2_";
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 80 ];
|
||||
networking.hosts."127.0.0.1" = [ "site1.local" "site2.local" ];
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
|
@ -54,10 +69,11 @@ import ./make-test-python.nix ({ pkgs, ... }:
|
|||
|
||||
wp_httpd.wait_for_unit("httpd")
|
||||
wp_nginx.wait_for_unit("nginx")
|
||||
wp_caddy.wait_for_unit("caddy")
|
||||
|
||||
site_names = ["site1.local", "site2.local"]
|
||||
|
||||
for machine in (wp_httpd, wp_nginx):
|
||||
for machine in (wp_httpd, wp_nginx, wp_caddy):
|
||||
for site_name in site_names:
|
||||
machine.wait_for_unit(f"phpfpm-wordpress-{site_name}")
|
||||
|
||||
|
|
Loading…
Reference in a new issue