2024-12-12 14:41:43 +01:00
|
|
|
# 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";
|
2023-09-17 18:13:35 +02:00
|
|
|
|
2024-03-16 17:34:42 +01:00
|
|
|
domains = [
|
2024-09-22 00:52:04 +02:00
|
|
|
"bandarretdurgence.ens.fr"
|
2024-03-16 17:34:42 +01:00
|
|
|
"boussole-sante.normalesup.eu"
|
2024-09-22 00:52:04 +02:00
|
|
|
"lanuit.ens.fr"
|
2024-03-16 17:34:42 +01:00
|
|
|
"simi.normalesup.eu"
|
2024-12-17 22:14:40 +01:00
|
|
|
"pub.dgnum.eu"
|
2024-03-16 17:34:42 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
buckets = [
|
2024-10-10 12:34:53 +02:00
|
|
|
"monorepo-terraform-state"
|
|
|
|
|
2024-09-22 00:52:04 +02:00
|
|
|
"banda-website"
|
2024-03-16 17:34:42 +01:00
|
|
|
"castopod-dgnum"
|
2024-09-22 00:52:04 +02:00
|
|
|
"hackens-website"
|
|
|
|
"nuit-website"
|
2024-03-16 17:34:42 +01:00
|
|
|
"peertube-videos-dgnum"
|
2024-12-17 22:14:40 +01:00
|
|
|
"landing-website"
|
2024-03-16 17:34:42 +01:00
|
|
|
] ++ domains;
|
|
|
|
|
|
|
|
mkHosted = host: builtins.map (b: "${b}.${host}");
|
2024-10-12 19:30:36 +02:00
|
|
|
|
|
|
|
ports = {
|
|
|
|
admin_api = 3903;
|
|
|
|
k2v_api = 3904;
|
|
|
|
rpc = 3901;
|
|
|
|
s3_api = 3900;
|
|
|
|
s3_web = 3902;
|
|
|
|
};
|
2024-02-02 10:51:31 +01:00
|
|
|
in
|
|
|
|
{
|
2025-01-11 05:48:31 +01:00
|
|
|
dgn-s3 = {
|
2023-09-11 11:17:52 +02:00
|
|
|
enable = true;
|
|
|
|
|
2025-01-11 05:48:31 +01:00
|
|
|
inherit ports;
|
2023-09-11 11:17:52 +02:00
|
|
|
|
2025-01-11 05:48:31 +01:00
|
|
|
data_dir = "/data/slow/garage/data";
|
|
|
|
metadata_dir = "/data/fast/garage/meta";
|
2023-09-17 18:13:35 +02:00
|
|
|
};
|
|
|
|
|
2025-01-11 05:48:31 +01:00
|
|
|
services.garage.settings = {
|
|
|
|
s3_api.root_domain = ".${host}";
|
|
|
|
s3_web.root_domain = ".${webHost}";
|
2023-09-17 18:13:35 +02:00
|
|
|
};
|
|
|
|
|
2023-09-11 18:54:17 +02:00
|
|
|
services.nginx.virtualHosts = {
|
2024-10-10 16:45:23 +02:00
|
|
|
"s3-admin.dgnum.eu" = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
|
|
|
|
|
|
|
locations."/".extraConfig = ''
|
2025-01-11 05:48:31 +01:00
|
|
|
proxy_pass http://127.0.0.1:${builtins.toString ports.admin_api};
|
2024-10-10 16:45:23 +02:00
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2023-09-11 18:54:17 +02:00
|
|
|
${host} = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
2023-10-05 23:28:27 +02:00
|
|
|
|
2024-03-16 17:34:42 +01:00
|
|
|
serverAliases = mkHosted host buckets;
|
2023-10-05 23:28:27 +02:00
|
|
|
|
2023-09-11 18:54:17 +02:00
|
|
|
locations."/".extraConfig = ''
|
2025-01-11 05:48:31 +01:00
|
|
|
proxy_pass http://127.0.0.1:${builtins.toString ports.s3_api};
|
2023-09-11 18:54:17 +02:00
|
|
|
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;
|
2023-12-08 14:52:51 +01:00
|
|
|
client_max_body_size 5G;
|
2023-09-11 18:54:17 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
${webHost} = {
|
|
|
|
enableACME = true;
|
|
|
|
forceSSL = true;
|
2023-10-05 23:28:27 +02:00
|
|
|
|
2024-03-16 17:34:42 +01:00
|
|
|
serverAliases = domains ++ (mkHosted webHost buckets);
|
2023-10-05 23:28:27 +02:00
|
|
|
|
2023-09-11 18:54:17 +02:00
|
|
|
locations."/".extraConfig = ''
|
2025-01-11 05:48:31 +01:00
|
|
|
proxy_pass http://127.0.0.1:${builtins.toString ports.s3_web};
|
2023-09-11 18:54:17 +02:00
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
2024-03-16 17:34:42 +01:00
|
|
|
proxy_set_header Host $host;
|
|
|
|
'';
|
2023-09-11 18:54:17 +02:00
|
|
|
};
|
2023-09-11 11:17:52 +02:00
|
|
|
};
|
|
|
|
}
|