2022-02-03 21:36:14 +02:00
|
|
|
{ aspect, config, lib, pkgs, tools, ... }:
|
2021-10-16 20:36:25 +03:00
|
|
|
with tools.nginx;
|
|
|
|
let
|
|
|
|
inherit (tools.meta) domain;
|
|
|
|
cfg = config.services.ipfs;
|
2021-11-29 02:38:59 +02:00
|
|
|
gwPort = config.portsStr.ipfsGateway;
|
2021-10-16 20:36:25 +03:00
|
|
|
in
|
|
|
|
{
|
2022-02-03 21:36:14 +02:00
|
|
|
imports = [
|
|
|
|
aspect.modules.ipfs
|
|
|
|
];
|
2021-10-16 20:36:25 +03:00
|
|
|
|
2022-02-03 01:44:06 +02:00
|
|
|
systemd.slices.remotefshost.sliceConfig = {
|
|
|
|
IOWeight = 5;
|
|
|
|
IOReadIOPSMax = [
|
|
|
|
"/dev/sda 100"
|
|
|
|
"/dev/sdb 100"
|
|
|
|
];
|
|
|
|
IOWriteIOPSMax = [
|
|
|
|
"/dev/sda 100"
|
|
|
|
"/dev/sdb 100"
|
|
|
|
];
|
|
|
|
IODviceLatencyTargetSec = [
|
|
|
|
"/dev/sda 500ms"
|
|
|
|
"/dev/sdb 500ms"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2021-12-04 03:51:21 +02:00
|
|
|
users.users.nginx.extraGroups = [ cfg.group ];
|
|
|
|
|
2021-10-16 20:36:25 +03:00
|
|
|
services.nginx.virtualHosts = {
|
|
|
|
"top-level.${domain}".locations = {
|
|
|
|
"~ ^/ip[fn]s" = {
|
2021-11-29 02:38:59 +02:00
|
|
|
proxyPass = "http://127.0.0.1:${gwPort}";
|
2021-10-16 20:36:25 +03:00
|
|
|
extraConfig = ''
|
|
|
|
add_header X-Content-Type-Options "";
|
|
|
|
add_header Access-Control-Allow-Origin *;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
"lain-ipfs.${domain}" = vhosts.basic // {
|
|
|
|
locations = {
|
|
|
|
"= /".return = "404";
|
|
|
|
"~ ^/ip[fn]s" = {
|
2021-11-29 02:38:59 +02:00
|
|
|
proxyPass = "http://127.0.0.1:${gwPort}";
|
2021-10-16 20:36:25 +03:00
|
|
|
extraConfig = ''
|
|
|
|
add_header X-Content-Type-Options "";
|
|
|
|
add_header Access-Control-Allow-Origin *;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
"/ipfs".extraConfig = "expires max;";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
"ipfs.admin.${domain}" = vhosts.basic // {
|
2021-12-04 03:51:21 +02:00
|
|
|
locations."/api".proxyPass = "http://unix:/run/ipfs/ipfs-api.sock:";
|
2021-11-29 02:38:59 +02:00
|
|
|
locations."/ipns/webui.ipfs.${domain}".proxyPass = "http://127.0.0.1:${gwPort}/ipns/webui.ipfs.${domain}";
|
2021-10-16 20:36:25 +03:00
|
|
|
locations."= /".return = "302 /ipns/webui.ipfs.${domain}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
services.oauth2_proxy.nginx.virtualHosts = [ "ipfs.admin.${domain}" ];
|
2021-10-16 17:42:26 +03:00
|
|
|
|
|
|
|
inherit (tools.acme.dns01) age;
|
|
|
|
|
|
|
|
security.acme.certs."ipfs.${domain}" = {
|
|
|
|
domain = "*.ipfs.${domain}";
|
|
|
|
extraDomainNames = [ "*.ipns.${domain}" ];
|
|
|
|
dnsProvider = "rfc2136";
|
|
|
|
group = "nginx";
|
|
|
|
inherit (tools.acme.dns01) credentialsFile;
|
|
|
|
};
|
|
|
|
|
|
|
|
services.nginx.virtualHosts."ipfs.${domain}" = vhosts.basic // {
|
|
|
|
serverName = "~^(.+)\.(ip[fn]s)\.${domain}$";
|
|
|
|
enableACME = false;
|
|
|
|
useACMEHost = "ipfs.${domain}";
|
|
|
|
locations = {
|
|
|
|
"/" = {
|
2021-11-29 02:38:59 +02:00
|
|
|
proxyPass = "http://127.0.0.1:${gwPort}";
|
2021-10-16 17:42:26 +03:00
|
|
|
extraConfig = ''
|
|
|
|
add_header X-Content-Type-Options "";
|
|
|
|
add_header Access-Control-Allow-Origin *;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2021-10-16 20:36:25 +03:00
|
|
|
}
|