infrastructure/machines/nixos/storage01/garage.nix

97 lines
2.2 KiB
Nix
Raw Normal View History

# SPDX-FileCopyrightText: 2024 Maurice Debray <maurice.debray@dgnum.eu>
# SPDX-FileCopyrightText: 2024 Tom Hubrecht <tom.hubrecht@dgnum.eu>
# SPDX-FileContributor: Ryan Lahfa <ryan.lahfa@dgnum.eu>
#
# SPDX-License-Identifier: EUPL-1.2
2023-09-11 11:17:52 +02:00
let
host = "s3.dgnum.eu";
webHost = "cdn.dgnum.eu";
domains = [
2024-09-22 00:52:04 +02:00
"bandarretdurgence.ens.fr"
"boussole-sante.normalesup.eu"
2024-09-22 00:52:04 +02:00
"lanuit.ens.fr"
"simi.normalesup.eu"
2024-12-17 22:14:40 +01:00
"pub.dgnum.eu"
];
buckets = [
"monorepo-terraform-state"
2024-09-22 00:52:04 +02:00
"banda-website"
"castopod-dgnum"
2024-09-22 00:52:04 +02:00
"hackens-website"
"nuit-website"
"peertube-videos-dgnum"
2024-12-17 22:14:40 +01:00
"landing-website"
] ++ domains;
mkHosted = host: builtins.map (b: "${b}.${host}");
ports = {
admin_api = 3903;
k2v_api = 3904;
rpc = 3901;
s3_api = 3900;
s3_web = 3902;
};
in
{
dgn-s3 = {
2023-09-11 11:17:52 +02:00
enable = true;
inherit ports;
2023-09-11 11:17:52 +02:00
data_dir = "/data/slow/garage/data";
metadata_dir = "/data/fast/garage/meta";
};
services.garage.settings = {
s3_api.root_domain = ".${host}";
s3_web.root_domain = ".${webHost}";
};
services.nginx.virtualHosts = {
"s3-admin.dgnum.eu" = {
enableACME = true;
forceSSL = true;
locations."/".extraConfig = ''
proxy_pass http://127.0.0.1:${builtins.toString ports.admin_api};
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
'';
};
${host} = {
enableACME = true;
forceSSL = true;
serverAliases = mkHosted host buckets;
locations."/".extraConfig = ''
proxy_pass http://127.0.0.1:${builtins.toString ports.s3_api};
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
# Disable buffering to a temporary file.
proxy_max_temp_file_size 0;
client_max_body_size 5G;
'';
};
${webHost} = {
enableACME = true;
forceSSL = true;
serverAliases = domains ++ (mkHosted webHost buckets);
locations."/".extraConfig = ''
proxy_pass http://127.0.0.1:${builtins.toString ports.s3_web};
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
'';
};
2023-09-11 11:17:52 +02:00
};
}