add options to the nixin-web.nix module
This commit is contained in:
parent
56a57675a1
commit
535a536b57
2 changed files with 44 additions and 31 deletions
|
@ -36,6 +36,11 @@
|
|||
ipv6 = "2a01:4f9:1a:9a05::2/128";
|
||||
};
|
||||
|
||||
nixin.web = {
|
||||
domain = "nixin.lab12.fr";
|
||||
http-port = 8081;
|
||||
};
|
||||
|
||||
# Enable ip forwarding to route packets for the local network connected to enp3s0
|
||||
boot.kernel.sysctl = {
|
||||
"net.ipv4.ip_forward" = 1;
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
{
|
||||
pkgs,
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
# Nixin web site
|
||||
{ config, pkgs, lib, ... }:
|
||||
|
||||
let
|
||||
inherit (lib) mkOption mkDefault;
|
||||
|
||||
nixin-web = pkgs.stdenv.mkDerivation {
|
||||
pname = "nixin-web";
|
||||
version = "0.1-alpha";
|
||||
|
@ -22,16 +21,24 @@ let
|
|||
};
|
||||
in
|
||||
{
|
||||
services.nginx.virtualHosts."nixin.lab12.fr" = {
|
||||
options = {
|
||||
nixin.web = {
|
||||
http-port = mkOption { type = lib.types.int; };
|
||||
domain = mkOption { type = lib.types.str; };
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
services.nginx.virtualHosts."${config.nixin.web.domain}" = {
|
||||
listen = [
|
||||
{
|
||||
addr = "127.0.0.1";
|
||||
port = 8081;
|
||||
port = config.nixin.web.http-port;
|
||||
ssl = false;
|
||||
}
|
||||
{
|
||||
addr = "[::1]";
|
||||
port = 8081;
|
||||
port = config.nixin.web.http-port;
|
||||
ssl = false;
|
||||
}
|
||||
];
|
||||
|
@ -43,11 +50,12 @@ in
|
|||
|
||||
services.traefik.dynamicConfigOptions.http.services."service-nixin-web" = {
|
||||
loadBalancer.servers = [
|
||||
{ url = "http://localhost:8081"; }
|
||||
{ url = "http://localhost:${toString config.nixin.web.http-port}"; }
|
||||
];
|
||||
};
|
||||
services.traefik.dynamicConfigOptions.http.routers."router-nixin-web" = {
|
||||
rule = "Host(`nixin.lab12.fr`)";
|
||||
rule = "Host(`${config.nixin.web.domain}`)";
|
||||
service = "service-nixin-web";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue