53 lines
1.8 KiB
Nix
53 lines
1.8 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
# domain = config.pbsds.nginx.mkDomain "cache-proxy";
|
|
domain = "cache-proxy.pbsds.net";
|
|
in
|
|
{
|
|
services.domeneshop-updater.targets = [ domain ];
|
|
|
|
# based on
|
|
# - https://wiki.nixos.org/wiki/FAQ/Private_Cache_Proxy
|
|
# - https://github.com/a1994sc/nixos-configs/blob/7927960877fc311745e55118823321851a618d80/archive/modules/binary-cache.nix#L42
|
|
# never tested, since this doesn't support multiple upstream caches
|
|
|
|
services.nginx.virtualHosts.${domain} = {
|
|
forceSSL = true; # addSSL = true;
|
|
enableACME = true; # useACMEHost = acmeDomain;
|
|
# serverAliases = [ "binarycache" ];
|
|
locations."/" = {
|
|
inherit (config.pbsds.nginx.allowList) extraConfig;
|
|
# proxyPass = "http://localhost:${toString config.services.nix-serve.port}";
|
|
# extraConfig = ''
|
|
# proxy_pass http://localhost:${toString config.services.nix-serve.port};
|
|
# proxy_set_header Host $host;
|
|
# proxy_set_header X-Real-IP $remote_addr;
|
|
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
# '';
|
|
};
|
|
|
|
# based on https://wiki.nixos.org/wiki/FAQ/Private_Cache_Proxy
|
|
locations."~ ^/nix-cache-info".extraConfig = ''
|
|
proxy_store on;
|
|
proxy_store_access user:rw group:rw all:r;
|
|
proxy_temp_path /mnt/nginx/nix-cache-info/temp;
|
|
root /mnt/nginx/nix-cache-info/store;
|
|
proxy_set_header Host "cache.nixos.org";
|
|
proxy_pass https://cache.nixos.org;
|
|
'';
|
|
locations."~ ^/nar/.+$".extraConfig = ''
|
|
proxy_store on;
|
|
proxy_store_access user:rw group:rw all:r;
|
|
proxy_temp_path /mnt/nginx/nar/temp;
|
|
root /mnt/nginx/nar/store;
|
|
|
|
proxy_set_header Host "cache.nixos.org";
|
|
proxy_pass https://cache.nixos.org;
|
|
'';
|
|
};
|
|
}
|