mirror of https://gitlab.crans.org/nounous/nixos
Reload de anubis, ajout de eclat et ajout de redirection pour favicon.ico
parent
abcf6977cc
commit
b639cfb18a
|
@ -1,71 +0,0 @@
|
||||||
{ pkgs, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
anubisBotsMirror = pkgs.writeText "anubis_bots_mirror.yaml" ''
|
|
||||||
- name: whitelist-crans
|
|
||||||
action: ALLOW
|
|
||||||
remote_addresses:
|
|
||||||
- 185.230.79.0/22
|
|
||||||
- 2a0c:700::/32
|
|
||||||
- 46.105.102.188/32
|
|
||||||
- 2001:41d0:2:d5bc::/128
|
|
||||||
|
|
||||||
- name: no-user-agent-string
|
|
||||||
action: DENY
|
|
||||||
expression: userAgent == ""
|
|
||||||
|
|
||||||
- name: ban-gpt
|
|
||||||
user_agent_regex: ".*gpt.*"
|
|
||||||
action: DENY
|
|
||||||
|
|
||||||
- name: ban-bot
|
|
||||||
user_agent_regex: ".*(b|B)ot.*"
|
|
||||||
action: DENY
|
|
||||||
|
|
||||||
- name: ban-WebKit
|
|
||||||
action: DENY
|
|
||||||
expression:
|
|
||||||
all:
|
|
||||||
- userAgent.startsWith("Mozilla")
|
|
||||||
- userAgent.matches("AppleWebKit")
|
|
||||||
- userAgent.matches("Safari")
|
|
||||||
- userAgent.matches("Chrome")
|
|
||||||
|
|
||||||
- name: ban-Barkrowler
|
|
||||||
user_agent_regex: ".*Barkrowler.*"
|
|
||||||
action: DENY
|
|
||||||
'';
|
|
||||||
anubisMirror = pkgs.writeText "anubis_mirror.json" ''
|
|
||||||
{
|
|
||||||
"bots": [
|
|
||||||
{
|
|
||||||
"import": "${anubisBotsMirror}"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "allow-repo",
|
|
||||||
"path_regex": "^...*",
|
|
||||||
"action": "ALLOW"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "deny-other",
|
|
||||||
"path_regex": ".*",
|
|
||||||
"action": "ALLOW"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
'';
|
|
||||||
in {
|
|
||||||
services.anubis = {
|
|
||||||
instances."mirror" = {
|
|
||||||
enable = true;
|
|
||||||
settings = {
|
|
||||||
BIND_NETWORK = "tcp";
|
|
||||||
BIND = "127.0.0.1:7779";
|
|
||||||
TARGET = "http://localhost:8890";
|
|
||||||
COOKIE_DOMAIN = "crans.org";
|
|
||||||
REDIRECT_DOMAINS = "eclat.crans.org,mirror.crans.org";
|
|
||||||
POLICY_FNAME = "${anubisMirror}";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
|
@ -161,6 +161,11 @@ in {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
virtualHosts = {
|
virtualHosts = {
|
||||||
|
"eclat" = {
|
||||||
|
anubisConfig = "${anubisMirror}";
|
||||||
|
httpOnly = true;
|
||||||
|
target = "172.16.10.104";
|
||||||
|
};
|
||||||
"eclats" = {
|
"eclats" = {
|
||||||
anubisConfig = "${anubisMirrors}";
|
anubisConfig = "${anubisMirrors}";
|
||||||
target = "172.16.10.104";
|
target = "172.16.10.104";
|
||||||
|
@ -199,7 +204,7 @@ in {
|
||||||
};
|
};
|
||||||
"wiki" = {
|
"wiki" = {
|
||||||
anubisConfig = "${anubisChallenge}";
|
anubisConfig = "${anubisChallenge}";
|
||||||
target = "172.16.10.161";
|
target = "[fd00::10:0:ff:fe01:6110]"; # l'ipv4 marche pas
|
||||||
serverAliases = [
|
serverAliases = [
|
||||||
"wikipedia"
|
"wikipedia"
|
||||||
];
|
];
|
||||||
|
|
|
@ -94,7 +94,14 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config.services = mkIf cfg.enable {
|
config = {
|
||||||
|
systemd.services = mapAttrs (
|
||||||
|
vhostName: vhostConfig: {
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
}
|
||||||
|
) cfg.virtualHosts;
|
||||||
|
|
||||||
|
services = mkIf cfg.enable {
|
||||||
anubis = {
|
anubis = {
|
||||||
defaultOptions.group = "nginx";
|
defaultOptions.group = "nginx";
|
||||||
instances = mapAttrs (
|
instances = mapAttrs (
|
||||||
|
@ -126,6 +133,7 @@ in
|
||||||
redirectConfig = mapAttrs (
|
redirectConfig = mapAttrs (
|
||||||
vhostName: vhostConfig: {
|
vhostName: vhostConfig: {
|
||||||
locations = mkIf ((substring 0 1 vhostConfig.target) != "/") {
|
locations = mkIf ((substring 0 1 vhostConfig.target) != "/") {
|
||||||
|
"/favicon.ico".root = "/var/www/logo/";
|
||||||
"/".proxyPass = "http://${vhostConfig.target}";
|
"/".proxyPass = "http://${vhostConfig.target}";
|
||||||
};
|
};
|
||||||
root = mkIf ((substring 0 1 vhostConfig.target) == "/") vhostConfig.target;
|
root = mkIf ((substring 0 1 vhostConfig.target) == "/") vhostConfig.target;
|
||||||
|
@ -165,4 +173,5 @@ in
|
||||||
virtualHosts = redirectConfig // aliasConfig // anubisConfig;
|
virtualHosts = redirectConfig // aliasConfig // anubisConfig;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue