Skip to content

Commit

Permalink
Fix nginx static serving in VM slightly better
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickvP committed Oct 13, 2024
1 parent d70368f commit a40f0d4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
4 changes: 3 additions & 1 deletion nix/infra.nix
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,16 @@ in rec {
'';
};
kn.django.package = "/kninfra-pub";
kn.django.serveMediaUsingNginx = false;
kn.settings.INFRA_REPO = "/kninfra-pub";
kn.mailserver.hostname = "mail.local";
programs.bash.shellAliases."vm.stop" = "poweroff";
system.fsPackages = [ pkgs.bindfs ];
# qemu settings:
virtualisation = {
diskSize = 1024;
# has to be at least this large to work around nginx bug
# pread() read only 16360 of 32768
msize = 32792;
# set up serial console
graphics = false;
# Share the PRJ_ROOT into the vm
Expand Down
30 changes: 8 additions & 22 deletions nix/services/kn/django.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,33 +38,19 @@ in {
defaultText = "pkgs.kninfra";
type = types.path;
};
serveMediaUsingNginx = mkOption {
# doesn't work in VM :(
description = ''
Use nginx to serve media directory.
'';
default = true;
type = types.bool;
};
};
config = lib.mkIf cfg.enable {
kn.shared.enable = true;
services.nginx = {
enable = true;
virtualHosts.kn = lib.mkMerge [
{
serverName = config.kn.settings.DOMAINNAME;
locations."/".extraConfig = ''
include ${pkgs.nginx}/conf/uwsgi_params;
uwsgi_pass unix:${config.kn.django.socket};
'';
}
{
locations = lib.mkIf cfg.serveMediaUsingNginx {
"/djmedia/".alias = "${cfg.package}/media/";
};
}
];
virtualHosts.kn = {
serverName = config.kn.settings.DOMAINNAME;
locations."/djmedia/".alias = "${cfg.package}/media/";
locations."/".extraConfig = ''
include ${pkgs.nginx}/conf/uwsgi_params;
uwsgi_pass unix:${config.kn.django.socket};
'';
};
};
systemd.sockets.kndjango = {
wantedBy = [ "sockets.target" ];
Expand Down

0 comments on commit a40f0d4

Please sign in to comment.