mirror of
https://github.com/Noratrieb/vps.git
synced 2026-01-14 08:45:02 +01:00
34 lines
1.3 KiB
Nix
34 lines
1.3 KiB
Nix
{ my-projects-versions, pkgs, lib, config, ... }:
|
|
let
|
|
upload-files = import (pkgs.fetchFromGitHub my-projects-versions."upload.files.noratrieb.dev".fetchFromGitHub);
|
|
in
|
|
{
|
|
age.secrets.upload_files_s3_secret.file = ../../secrets/upload_files_s3_secret.age;
|
|
|
|
systemd.services.upload-files = {
|
|
description = "upload.files.noratrieb.dev file uploader for files.noratrieb.dev";
|
|
wantedBy = [ "multi-user.target" ];
|
|
after = [ "network.target" ];
|
|
environment = {
|
|
UPLOAD_FILES_NORATRIEB_DEV_BUCKET = "files.noratrieb.dev";
|
|
UPLOAD_FILES_NORATRIEB_DEV_ENDPOINT = "http://localhost:3900";
|
|
UPLOAD_FILES_NORATRIEB_DEV_REGION = "garage";
|
|
};
|
|
serviceConfig = {
|
|
DynamicUser = true;
|
|
ExecStart = "${lib.getExe (upload-files {inherit pkgs;})}";
|
|
EnvironmentFile = [ config.age.secrets.upload_files_s3_secret.path ];
|
|
};
|
|
};
|
|
|
|
services.caddy.virtualHosts."upload.files.noratrieb.dev" = {
|
|
logFormat = "";
|
|
extraConfig = ''
|
|
encode zstd gzip
|
|
# we need HTTP/2 here because the server doesn't work with HTTP/1.1
|
|
# because it will send early 401 responses during the upload without consuming the body
|
|
# (this has been mostly fixed but still keep it)
|
|
reverse_proxy * h2c://localhost:3050
|
|
'';
|
|
};
|
|
}
|