mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-22 16:55:38 +00:00
move caddy config into separate file
This commit is contained in:
parent
90bc2ecd49
commit
b4ba0706c0
26
modules/services/caddy.nix
Normal file
26
modules/services/caddy.nix
Normal file
@ -0,0 +1,26 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
|
||||
in {
|
||||
|
||||
options = {
|
||||
caddyServers = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
description = "Caddy JSON configs for http servers";
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
adapter = "''"; # Required to enable JSON
|
||||
configFile = pkgs.writeText "Caddyfile"
|
||||
(builtins.toJSON { apps.http.servers = config.caddyServers; });
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
@ -7,6 +7,8 @@ let
|
||||
|
||||
in {
|
||||
|
||||
imports = [ ./caddy.nix ];
|
||||
|
||||
options = {
|
||||
bookServer = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
@ -26,25 +28,16 @@ in {
|
||||
};
|
||||
};
|
||||
|
||||
services.caddy = {
|
||||
enable = true;
|
||||
adapter = "''"; # Required to enable JSON
|
||||
configFile = pkgs.writeText "Caddyfile" (builtins.toJSON {
|
||||
apps.http.servers = {
|
||||
calibre = {
|
||||
listen = [ ":443" ];
|
||||
routes = [{
|
||||
match = [{ host = [ config.bookServer ]; }];
|
||||
handle = [{
|
||||
handler = "reverse_proxy";
|
||||
upstreams = [{ dial = "localhost:8083"; }];
|
||||
headers.request.add."X-Script-Name" = [ "/calibre-web" ];
|
||||
}];
|
||||
}];
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
caddyServers.calibre = {
|
||||
listen = [ ":443" ];
|
||||
routes = [{
|
||||
match = [{ host = [ config.bookServer ]; }];
|
||||
handle = [{
|
||||
handler = "reverse_proxy";
|
||||
upstreams = [{ dial = "localhost:8083"; }];
|
||||
headers.request.add."X-Script-Name" = [ "/calibre-web" ];
|
||||
}];
|
||||
}];
|
||||
};
|
||||
|
||||
networking.firewall.interfaces.calibre = { allowedTCPPorts = [ 80 443 ]; };
|
||||
|
Loading…
Reference in New Issue
Block a user