nixos/dependency-track: fix nginx config for frontend (#393041)

authored by xanderio and committed by GitHub 71ae33ed c6c0dd59

+39 -16
+20 -2
nixos/modules/services/web-apps/dependency-track.nix
··· 509 509 upstreams.dependency-track.servers."localhost:${toString cfg.port}" = { }; 510 510 virtualHosts.${cfg.nginx.domain} = { 511 511 locations = { 512 - "/".alias = "${cfg.package.frontend}/dist/"; 512 + "/" = { 513 + alias = "${cfg.package.frontend}/dist/"; 514 + index = "index.html"; 515 + tryFiles = "$uri $uri/ /index.html"; 516 + extraConfig = '' 517 + location ~ (index\.html)$ { 518 + add_header Cache-Control "max-age=0, no-cache, no-store, must-revalidate"; 519 + add_header Pragma "no-cache"; 520 + add_header Expires 0; 521 + } 522 + ''; 523 + }; 513 524 "/api".proxyPass = "http://dependency-track"; 514 - "= /static/config.json".alias = frontendConfigFile; 525 + "= /static/config.json" = { 526 + alias = frontendConfigFile; 527 + extraConfig = '' 528 + add_header Cache-Control "max-age=0, no-cache, no-store, must-revalidate"; 529 + add_header Pragma "no-cache"; 530 + add_header Expires 0; 531 + ''; 532 + }; 515 533 }; 516 534 }; 517 535 };
+19 -14
nixos/tests/dependency-track.nix
··· 45 45 }; 46 46 }; 47 47 48 - testScript = '' 49 - import json 48 + testScript = 49 + # python 50 + '' 51 + import json 52 + 53 + start_all() 50 54 51 - start_all() 55 + server.wait_for_unit("dependency-track.service") 56 + server.wait_until_succeeds( 57 + "journalctl -o cat -u dependency-track.service | grep 'Dependency-Track is ready'" 58 + ) 59 + server.wait_for_open_port(${toString dependencyTrackPort}) 52 60 53 - server.wait_for_unit("dependency-track.service") 54 - server.wait_until_succeeds( 55 - "journalctl -o cat -u dependency-track.service | grep 'Dependency-Track is ready'" 56 - ) 57 - server.wait_for_open_port(${toString dependencyTrackPort}) 61 + with subtest("version api returns correct version"): 62 + version = json.loads( 63 + server.succeed("curl http://localhost/api/version") 64 + ) 65 + assert version["version"] == "${pkgs.dependency-track.version}" 58 66 59 - with subtest("version api returns correct version"): 60 - version = json.loads( 61 - server.succeed("curl http://localhost/api/version") 62 - ) 63 - assert version["version"] == "${pkgs.dependency-track.version}" 64 - ''; 67 + with subtest("nginx serves frontend"): 68 + server.succeed("curl http://localhost/ | grep \"<title>Dependency-Track</title>\"") 69 + ''; 65 70 } 66 71 )