egirls-nixos/heartles-xyz-proxy.nix

58 lines
1.3 KiB
Nix
Raw Normal View History

2024-02-29 21:08:22 +00:00
{ config, lib, ... }: {
networking.firewall.allowedTCPPorts = [ 80 443 ];
security.acme = {
acceptTerms = true;
defaults.email = "admin+acme@heartles.xyz";
certs."STAR.home.heartles.xyz" = {
domain = "*.home.heartles.xyz";
dnsProvider = "namecheap";
credentialsFile = "/etc/nixos-secrets/namecheap-acme";
group = "nginx";
};
};
services.nginx = {
enable = true;
recommendedProxySettings = true;
2024-02-29 21:29:08 +00:00
upstreams."home-server".extraConfig = ''
include /etc/nixos-secrets/nginx-home-server-upstream.conf;
'';
2024-02-29 21:08:22 +00:00
virtualHosts = {
"*.home.heartles.xyz" = {
listen = [
{
port = 443;
addr = "0.0.0.0";
ssl = true;
}
{
port = 80;
addr = "0.0.0.0";
}
{
port = 443;
addr = "[::]";
ssl = true;
}
{
port = 80;
addr = "[::]";
}
];
useACMEHost = "STAR.home.heartles.xyz";
forceSSL = true;
locations."/" = {
proxyWebsockets = true;
2024-02-29 21:29:08 +00:00
proxyPass = "https://home-server";
2024-02-29 21:08:22 +00:00
extraConfig = ''
proxy_ssl_name $host;
'';
};
};
};
};
}