mirror of https://gitlab.crans.org/nounous/nixos
Merge branch 'reverseproxy' into 'main'
Reverseproxy See merge request nounous/nixos!105merge-requests/105/merge
commit
4ed6287f05
|
|
@ -1,3 +1,4 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
name = "collabora";
|
||||
description = "Collabora du Crans";
|
||||
|
|
@ -9,6 +10,13 @@
|
|||
srv-nat.enable = true;
|
||||
};
|
||||
|
||||
reverseproxy.vhosts = {
|
||||
"collabora" = {
|
||||
proxyPass = config.networking.adm.ipv4.address;
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
|
||||
monitoring = {
|
||||
nginx.enable = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
name = "livre";
|
||||
description = "Editeur de PDF en ligne via Stirling-PDF";
|
||||
|
|
@ -9,6 +10,17 @@
|
|||
srv-nat.enable = true;
|
||||
};
|
||||
|
||||
reverseproxy.vhosts = {
|
||||
"pdf" = {
|
||||
proxyPass = config.networking.adm.ipv4.address;
|
||||
aliases = [
|
||||
"livre"
|
||||
"stirling"
|
||||
"stirling-pdf"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
monitoring = {
|
||||
nginx.enable = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
name = "mediakiwi";
|
||||
description = "Wiki du Crans";
|
||||
|
|
@ -9,6 +10,30 @@
|
|||
srv-nat.enable = true;
|
||||
};
|
||||
|
||||
reverseproxy.vhosts = {
|
||||
"mediawiki" = {
|
||||
anubisConfig = [
|
||||
{
|
||||
name = "allow-mediawiki-images";
|
||||
path_regex = "^/w/images/.*";
|
||||
action = "ALLOW";
|
||||
}
|
||||
{
|
||||
name = "allow-mediawiki-api";
|
||||
path_regex = "^/w/api.php.*";
|
||||
action = "ALLOW";
|
||||
}
|
||||
{
|
||||
name = "challenge-other";
|
||||
path_regex = ".*";
|
||||
action = "CHALLENGE";
|
||||
}
|
||||
];
|
||||
proxyPass = config.networking.adm.ipv4.address;
|
||||
aliases = [ "mediakiwi" ];
|
||||
};
|
||||
};
|
||||
|
||||
monitoring = {
|
||||
nginx.enable = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
name = "nextcloud";
|
||||
description = "Nextcloud du Crans";
|
||||
|
|
@ -16,6 +17,8 @@
|
|||
};
|
||||
};
|
||||
|
||||
reverseproxy.vhosts."nextcloud".proxyPass = config.networking.adm.ipv4.address;
|
||||
|
||||
homeAdh.enable = true;
|
||||
|
||||
monitoring = {
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
{ config, lib, ... }:
|
||||
{
|
||||
name = "periodique";
|
||||
description = "Frontend Matrix du Crans (element)";
|
||||
|
|
@ -9,6 +10,15 @@
|
|||
srv-nat.enable = true;
|
||||
};
|
||||
|
||||
reverseproxy.vhosts = {
|
||||
"element".proxyPass = config.networking.adm.ipv4.address;
|
||||
"matrix-to".serveLocalFiles = lib.fetchFromCrans {
|
||||
repo = "matrixto";
|
||||
rev = "bd639c5e0d7664dcd44d07ef70abb5f59919f714";
|
||||
hash = "sha256-kiK4lGF8RCioKYWoM8CPiDLuESxenXQvo33ns1hDMwc=";
|
||||
};
|
||||
};
|
||||
|
||||
monitoring = {
|
||||
nginx.enable = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
{
|
||||
hosts,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
|
|
@ -61,24 +62,6 @@ let
|
|||
}
|
||||
];
|
||||
|
||||
anubisWiki = [
|
||||
{
|
||||
name = "allow-mediawiki-images";
|
||||
path_regex = "^/w/images/.*";
|
||||
action = "ALLOW";
|
||||
}
|
||||
{
|
||||
name = "allow-mediawiki-api";
|
||||
path_regex = "^/w/api.php.*";
|
||||
action = "ALLOW";
|
||||
}
|
||||
{
|
||||
name = "challenge-other";
|
||||
path_regex = ".*";
|
||||
action = "CHALLENGE";
|
||||
}
|
||||
];
|
||||
|
||||
installPartySite = pkgs.python3Packages.buildPythonApplication {
|
||||
name = "site-install-party";
|
||||
pyproject = false;
|
||||
|
|
@ -121,13 +104,9 @@ in
|
|||
crans = {
|
||||
reverseProxy = {
|
||||
enable = true;
|
||||
virtualHosts = {
|
||||
virtualHosts = (lib.concatMapAttrs (_: c: c.reverseproxy.vhosts) hosts) // {
|
||||
"autoconfig".serveLocalFiles = ./staticsites/autoconfig;
|
||||
"cas".proxyPass = "172.16.10.120";
|
||||
"collabora" = {
|
||||
proxyPass = "172.16.10.149";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
"eclat" = {
|
||||
anubisConfig = anubisMirrors;
|
||||
httpOnly = true;
|
||||
|
|
@ -137,28 +116,27 @@ in
|
|||
anubisConfig = anubisMirrors;
|
||||
proxyPass = "172.16.10.104";
|
||||
};
|
||||
"element".proxyPass = "172.16.10.118";
|
||||
"ethercalc" = {
|
||||
proxyPass = "172.16.10.133:8000";
|
||||
serverAliases = [ "excel" ];
|
||||
aliases = [ "excel" ];
|
||||
};
|
||||
"framadate".proxyPass = "172.16.10.109";
|
||||
"grafana" = {
|
||||
proxyPass = "172.16.10.121:3000";
|
||||
serverAliases = [ "fyre" ];
|
||||
aliases = [ "fyre" ];
|
||||
};
|
||||
"imprimante" = {
|
||||
proxyPass = "172.16.10.131";
|
||||
serverAliases = [ "helloworld" ];
|
||||
aliases = [ "helloworld" ];
|
||||
};
|
||||
"intranet" = {
|
||||
proxyPass = "172.16.10.156";
|
||||
serverAliases = [ "re2o" ];
|
||||
aliases = [ "re2o" ];
|
||||
};
|
||||
"install-party" = {
|
||||
anubisConfig = anubisChallenge;
|
||||
serveLocalFiles = "${installPartySite}/site";
|
||||
serverAliases = [
|
||||
aliases = [
|
||||
"i-p"
|
||||
"adopteunmanchot"
|
||||
"adopteunpingouin"
|
||||
|
|
@ -173,11 +151,6 @@ in
|
|||
rev = "bd639c5e0d7664dcd44d07ef70abb5f59919f714";
|
||||
hash = "sha256-kiK4lGF8RCioKYWoM8CPiDLuESxenXQvo33ns1hDMwc=";
|
||||
};
|
||||
"mediawiki" = {
|
||||
anubisConfig = anubisWiki;
|
||||
proxyPass = "172.16.10.144";
|
||||
serverAliases = [ "mediakiwi" ];
|
||||
};
|
||||
"mirrors" = {
|
||||
anubisConfig = anubisMirrors;
|
||||
proxyPass = "172.16.10.104";
|
||||
|
|
@ -188,21 +161,12 @@ in
|
|||
proxyPass = "172.16.10.104";
|
||||
};
|
||||
"nekorale".globalRedirect = "perso.crans.org/club-nekorale";
|
||||
"nextcloud".proxyPass = "172.16.10.146";
|
||||
"owncloud".proxyPass = "172.16.10.136";
|
||||
"pad".proxyPass = "172.16.10.130:9001";
|
||||
"pdf" = {
|
||||
proxyPass = "172.16.10.140";
|
||||
serverAliases = [
|
||||
"livre"
|
||||
"stirling"
|
||||
"stirling-pdf"
|
||||
];
|
||||
};
|
||||
"perso" = {
|
||||
anubisConfig = anubisPerso;
|
||||
proxyPass = "172.16.10.31";
|
||||
serverAliases = [ "clubs" ];
|
||||
aliases = [ "clubs" ];
|
||||
};
|
||||
"pot-vieux".globalRedirect = "perso.crans.org/club-vieux";
|
||||
"re2o-dev".proxyPass = "172.16.10.166";
|
||||
|
|
@ -214,23 +178,19 @@ in
|
|||
"snl".globalRedirect = "perso.crans.org/sonetlumens";
|
||||
"test-melon".proxyPass = "172.16.10.150:8080";
|
||||
"tmpad".proxyPass = "172.16.10.130:9002";
|
||||
"vaultwarden" = {
|
||||
proxyPass = "172.16.10.159";
|
||||
serverAliases = [ "pass" ];
|
||||
};
|
||||
"webirc".proxyPass = "172.16.10.31:9000";
|
||||
"webmail" = {
|
||||
proxyPass = "172.16.10.107";
|
||||
serverAliases = [ "roundcube" ];
|
||||
aliases = [ "roundcube" ];
|
||||
};
|
||||
"wiki" = {
|
||||
anubisConfig = anubisChallenge;
|
||||
proxyPass = "172.16.10.161";
|
||||
serverAliases = [ "wikipedia" ];
|
||||
aliases = [ "wikipedia" ];
|
||||
};
|
||||
"_crans-org" = {
|
||||
serveLocalFiles = homepagePkg;
|
||||
serverAliases = [ "www" ];
|
||||
aliases = [ "www" ];
|
||||
};
|
||||
"zero".proxyPass = "172.16.10.130";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
{ config, ... }:
|
||||
{
|
||||
name = "vaultwarden";
|
||||
description = "Vaultarden du crans, gestionnaire de mot de passe";
|
||||
|
|
@ -9,6 +10,13 @@
|
|||
srv-nat.enable = true;
|
||||
};
|
||||
|
||||
reverseproxy.vhosts = {
|
||||
"vaultwarden" = {
|
||||
proxyPass = config.networking.adm.ipv4.address;
|
||||
aliases = [ "pass" ];
|
||||
};
|
||||
};
|
||||
|
||||
monitoring = {
|
||||
nginx.enable = true;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ in
|
|||
./monitoring.nix
|
||||
./networking.nix
|
||||
./resticClient.nix
|
||||
./reverseproxy.nix
|
||||
./users.nix
|
||||
];
|
||||
options.enable = mkOption {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
# Info des endpoints à Reverseproxy
|
||||
# Ne pas confondre avec ../services/reverseproxy.nix qui
|
||||
# définit le service de reverseproxy à proprement parlé
|
||||
# Les options font parties d’évaluation différentes et ne sont donc pas
|
||||
# conflictuelles.
|
||||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
in
|
||||
{
|
||||
options.reverseproxy = {
|
||||
vhosts = mkOption {
|
||||
type = types.attrsOf (types.submodule ./reverseproxyVhost.nix);
|
||||
description = ''
|
||||
Hosts virtuels à reverseproxer.
|
||||
'';
|
||||
default = { };
|
||||
example = {
|
||||
"framadate" = {
|
||||
host = "176.16.10.128:8000";
|
||||
aliases = [
|
||||
"everything"
|
||||
"voyager"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
# A virtual host for the reverseproxy
|
||||
{ lib, ... }:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
|
||||
aliases = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Définit des alias de redirection.
|
||||
'';
|
||||
example = [
|
||||
"everything"
|
||||
"voyager"
|
||||
];
|
||||
};
|
||||
|
||||
proxyPass = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Endpoint de destination à exposer.
|
||||
'';
|
||||
example = "172.16.10.128:8000";
|
||||
};
|
||||
|
||||
serveLocalFiles = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = ''
|
||||
Chemin vers un dossier à exposer statiquement.
|
||||
'';
|
||||
example = "/var/local/www";
|
||||
};
|
||||
|
||||
globalRedirect = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Redirection vers une autre adresse.
|
||||
'';
|
||||
};
|
||||
|
||||
anubisConfig = mkOption {
|
||||
type = types.nullOr (types.listOf types.attrs);
|
||||
default = null;
|
||||
description = ''
|
||||
Configuration pour anubis
|
||||
'';
|
||||
};
|
||||
|
||||
httpOnly = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Interdit les connexions en https
|
||||
'';
|
||||
example = "true";
|
||||
};
|
||||
|
||||
proxyWebsockets = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Activer les websockets
|
||||
'';
|
||||
example = "true";
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
|
@ -14,7 +14,6 @@ let
|
|||
];
|
||||
|
||||
inherit (lib)
|
||||
literalExpression
|
||||
mkEnableOption
|
||||
mkIf
|
||||
mkOption
|
||||
|
|
@ -29,90 +28,20 @@ in
|
|||
enable = mkEnableOption "Configuration du reverseproxy.";
|
||||
|
||||
virtualHosts = mkOption {
|
||||
type = types.attrsOf (
|
||||
types.submodule {
|
||||
options = {
|
||||
serverAliases = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [ ];
|
||||
example = [
|
||||
"everything"
|
||||
"voyager"
|
||||
];
|
||||
description = ''
|
||||
Déclaration des alias.
|
||||
'';
|
||||
};
|
||||
|
||||
proxyPass = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Indique la destination à proxy.
|
||||
'';
|
||||
example = "172.16.10.128:8000";
|
||||
};
|
||||
|
||||
serveLocalFiles = mkOption {
|
||||
type = types.nullOr types.path;
|
||||
default = null;
|
||||
description = ''
|
||||
Chemin vers un dossier à exposer statiquement.
|
||||
'';
|
||||
example = "/var/local/adopter-un-manchot";
|
||||
};
|
||||
|
||||
globalRedirect = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
description = ''
|
||||
Si définie, toutes les requêtes sont redirigées (via 301) sur cet hôte.
|
||||
'';
|
||||
example = "perso.crans.org/club";
|
||||
};
|
||||
|
||||
anubisConfig = mkOption {
|
||||
type = types.nullOr (types.listOf types.attrs);
|
||||
default = null;
|
||||
description = ''
|
||||
Configuration pour anubis
|
||||
'';
|
||||
};
|
||||
|
||||
httpOnly = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Interdit les connexions en https
|
||||
'';
|
||||
example = "true";
|
||||
};
|
||||
|
||||
proxyWebsockets = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Activer les websockets
|
||||
'';
|
||||
example = "true";
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
type = types.attrsOf (types.submodule ../info/reverseproxyVhost.nix);
|
||||
|
||||
default = { };
|
||||
|
||||
example = literalExpression ''
|
||||
{
|
||||
"framadate" = {
|
||||
host = "176.16.10.128:8000";
|
||||
serverAliases = [
|
||||
"everything"
|
||||
"voyager"
|
||||
]
|
||||
};
|
||||
example = {
|
||||
"framadate" = {
|
||||
host = "176.16.10.128:8000";
|
||||
aliases = [
|
||||
"everything"
|
||||
"voyager"
|
||||
];
|
||||
};
|
||||
'';
|
||||
};
|
||||
|
||||
description = "Déclaration des machines.";
|
||||
};
|
||||
};
|
||||
|
|
@ -208,18 +137,14 @@ in
|
|||
error_log /var/log/nginx/host/${vhostName}/error.log;
|
||||
'';
|
||||
|
||||
# Les alias : vhostName × otherTld U serverAliases × allTld
|
||||
aliases =
|
||||
lib.foldr
|
||||
(
|
||||
tld: acc:
|
||||
acc
|
||||
++ (lib.foldr (alias: acc: acc ++ [ (mkHostName alias tld) ]) [
|
||||
(mkHostName vhostName tld)
|
||||
] vhostConfig.serverAliases)
|
||||
)
|
||||
(lib.foldr (alias: acc: acc ++ [ (mkHostName alias mainTld) ]) [ ] vhostConfig.serverAliases)
|
||||
otherTld;
|
||||
# Les alias : vhostName × otherTld U aliases × allTld
|
||||
aliases = lib.foldr (
|
||||
tld: acc:
|
||||
acc
|
||||
++ (lib.foldr (alias: acc: acc ++ [ (mkHostName alias tld) ]) [
|
||||
(mkHostName vhostName tld)
|
||||
] vhostConfig.aliases)
|
||||
) (lib.foldr (alias: acc: acc ++ [ (mkHostName alias mainTld) ]) [ ] vhostConfig.aliases) otherTld;
|
||||
in
|
||||
{
|
||||
# Configuration du service à proxy.
|
||||
|
|
|
|||
Loading…
Reference in New Issue