web-redirect: init new service for simple domain redirects
This commit is contained in:
parent
addbf7ac3e
commit
55000c365a
4 changed files with 42 additions and 19 deletions
|
@ -8,5 +8,6 @@
|
|||
./navidrome.nix
|
||||
./pipewire-low-latency.nix
|
||||
./remote-builder.nix
|
||||
./web-redirect.nix
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
30
services/web-redirect.nix
Normal file
30
services/web-redirect.nix
Normal file
|
@ -0,0 +1,30 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkIf mkOption mkEnableOption types;
|
||||
cfg = config.fountain.services.web-redirect;
|
||||
in
|
||||
{
|
||||
options.fountain.services.web-redirect = {
|
||||
enable = mkEnableOption "Module to do simple 301 redirects from one domain to another";
|
||||
domains = mkOption {
|
||||
type = types.attrsOf types.str;
|
||||
description = "Mapping from source domain to destination domain";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
virtualHosts = builtins.mapAttrs
|
||||
(name: value: {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations."/".return = "301 https://${value}$request_uri";
|
||||
})
|
||||
cfg.domains;
|
||||
};
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ 80 443 ];
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue