nginx: more ssl tinkering

This commit is contained in:
Zynh Ludwig 2024-12-27 20:14:55 -08:00
parent 2265f6d144
commit 250f354067
4 changed files with 41 additions and 30 deletions

View file

@ -16,7 +16,7 @@ in
# TODO: Force ssl
# addSSL = true;
serverName = "git.zynh.me";
useACMEHost = lib.mkIf ACMEEnabled "scarlet.zynh.me";
useACMEHost = lib.mkIf ACMEEnabled "permafrost";
locations."/" = {
proxyPass = "http://localhost:3032";
};

View file

@ -9,34 +9,44 @@ in
enable = lib.mkEnableOption "foundry nixos module";
};
config = lib.mkIf cfg.enable {
permafrost.nginx.enable = lib.mkDefault true;
permafrost.nginx.certDomains = lib.mkIf ACMEEnabled [ "scarlet.zynh.me" ];
services.nginx.virtualHosts."scarlet.zynh.me" = {
# TODO: Force ssl
# addSSL = true;
serverName = "scarlet.zynh.me";
useACMEHost = lib.mkIf ACMEEnabled "scarlet.zynh.me";
locations."/" = {
extraConfig = /* nginx */ ''
# Set proxy headers
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
config = lib.mkIf cfg.enable (lib.mkMerge [
{
permafrost.nginx.enable = lib.mkDefault true;
}
{
# permafrost.nginx.certDomains = lib.mkIf ACMEEnabled [ "scarlet.zynh.me" ];
services.nginx.virtualHosts."scarlet.zynh.me" = {
# TODO: Force ssl
# addSSL = true;
serverName = "scarlet.zynh.me";
useACMEHost = lib.mkIf ACMEEnabled "permafrost";
locations."/.well-known/acme-challenge" = {
root = "/var/lib/acme/.challenges";
};
locations."/" = {
extraConfig = /* nginx */ ''
# Set proxy headers
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
# These are important to support WebSockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
'';
proxyPass = "http://localhost:30000";
# These are important to support WebSockets
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
'';
proxyPass = "http://localhost:30000";
};
};
};
services.nginx.virtualHosts."ddbimporter.zynh.me" = {
# TODO: Force ssl
# addSSL = true;
serverName = "ddbimporter.zynh.me";
locations."/".proxyPass = "http://localhost:3232";
};
};
}
{
permafrost.nginx.certDomains = lib.mkIf ACMEEnabled [ "ddbimporter.zynh.me" ];
services.nginx.virtualHosts."ddbimporter.zynh.me" = {
# TODO: Force ssl
# addSSL = true;
useACMEHost = lib.mkIf ACMEEnabled "permafrost";
serverName = "ddbimporter.zynh.me";
locations."/".proxyPass = "http://localhost:3232";
};
}
]);
}

View file

@ -28,6 +28,7 @@ in
security.acme.certs.permafrost = lib.mkIf cfg.enableACME {
email = "Zynh0722@gmail.com";
domain = "scarlet.zynh.me";
group = config.services.nginx.group;
renewInterval = "weekly";
server =
if cfg.useStagingServer

View file

@ -29,7 +29,7 @@ in
# TODO: Force ssl
# addSSL = true;
serverName = "nyazoom.zynh.me";
useACMEHost = lib.mkIf ACMEEnabled "scarlet.zynh.me";
useACMEHost = lib.mkIf ACMEEnabled "permafrost";
locations."/" = {
proxyPass = "http://localhost:3000";
extraConfig = /* nginx */ ''