Skip to content

Commit 24a8c64

Browse files
nixos/caddy: Fix default log file for http:// hostnames (#371802)
2 parents 24a2206 + dacfe3f commit 24a8c64

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

nixos/modules/services/web-servers/caddy/vhost-options.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ in
5858
logFormat = mkOption {
5959
type = types.lines;
6060
default = ''
61-
output file ${cfg.logDir}/access-${config.hostName}.log
61+
output file ${cfg.logDir}/access-${lib.replaceStrings [ "/" " " ] [ "_" "_" ] config.hostName}.log
6262
'';
6363
defaultText = ''
6464
output file ''${config.services.caddy.logDir}/access-''${hostName}.log

nixos/tests/caddy.nix

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ import ./make-test-python.nix (
4141
"http://localhost:8081" = { };
4242
};
4343
};
44+
specialisation.multiple-hostnames.configuration = {
45+
services.caddy.virtualHosts = {
46+
"http://localhost:8080 http://localhost:8081" = { };
47+
};
48+
};
4449
specialisation.rfc42.configuration = {
4550
services.caddy.settings = {
4651
apps.http.servers.default = {
@@ -70,7 +75,7 @@ import ./make-test-python.nix (
7075
services.caddy = {
7176
package = pkgs.caddy.withPlugins {
7277
plugins = [ "github.com/caddyserver/[email protected]" ];
73-
hash = "sha256-zgMdtOJbmtRSfTlrrg8njr11in2C7OAXLB+34V23jek=";
78+
hash = "sha256-BorJJWICgAWU7DrpDZJWifMnIYtGWldt/4S1VELwGJI=";
7479
};
7580
configFile = pkgs.writeText "Caddyfile" ''
7681
{
@@ -93,6 +98,7 @@ import ./make-test-python.nix (
9398
explicitConfigFile = "${nodes.webserver.system.build.toplevel}/specialisation/explicit-config-file";
9499
justReloadSystem = "${nodes.webserver.system.build.toplevel}/specialisation/config-reload";
95100
multipleConfigs = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-configs";
101+
multipleHostnames = "${nodes.webserver.system.build.toplevel}/specialisation/multiple-hostnames";
96102
rfc42Config = "${nodes.webserver.system.build.toplevel}/specialisation/rfc42";
97103
withPluginsConfig = "${nodes.webserver.system.build.toplevel}/specialisation/with-plugins";
98104
in
@@ -117,6 +123,13 @@ import ./make-test-python.nix (
117123
webserver.wait_for_open_port(8080)
118124
webserver.wait_for_open_port(8081)
119125
126+
with subtest("a virtual host with multiple hostnames works"):
127+
webserver.succeed(
128+
"${multipleHostnames}/bin/switch-to-configuration test >&2"
129+
)
130+
webserver.wait_for_open_port(8080)
131+
webserver.wait_for_open_port(8081)
132+
120133
with subtest("rfc42 settings config"):
121134
webserver.succeed(
122135
"${rfc42Config}/bin/switch-to-configuration test >&2"

0 commit comments

Comments
 (0)