Unverified Commit 71ae33ed authored by xanderio's avatar xanderio Committed by GitHub
Browse files

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

parents c6c0dd59 4bc3f439
Loading
Loading
Loading
Loading
+20 −2
Original line number Diff line number Diff line
@@ -509,9 +509,27 @@ in
      upstreams.dependency-track.servers."localhost:${toString cfg.port}" = { };
      virtualHosts.${cfg.nginx.domain} = {
        locations = {
          "/".alias = "${cfg.package.frontend}/dist/";
          "/" = {
            alias = "${cfg.package.frontend}/dist/";
            index = "index.html";
            tryFiles = "$uri $uri/ /index.html";
            extraConfig = ''
              location ~ (index\.html)$ {
                add_header Cache-Control "max-age=0, no-cache, no-store, must-revalidate";
                add_header Pragma "no-cache";
                add_header Expires 0;
              }
            '';
          };
          "/api".proxyPass = "http://dependency-track";
          "= /static/config.json".alias = frontendConfigFile;
          "= /static/config.json" = {
            alias = frontendConfigFile;
            extraConfig = ''
              add_header Cache-Control "max-age=0, no-cache, no-store, must-revalidate";
              add_header Pragma "no-cache";
              add_header Expires 0;
            '';
          };
        };
      };
    };
+19 −14
Original line number Diff line number Diff line
@@ -45,7 +45,9 @@ import ./make-test-python.nix (
        };
    };

    testScript = ''
    testScript =
      # python
      ''
        import json

        start_all()
@@ -61,6 +63,9 @@ import ./make-test-python.nix (
            server.succeed("curl http://localhost/api/version")
          )
          assert version["version"] == "${pkgs.dependency-track.version}"

        with subtest("nginx serves frontend"):
          server.succeed("curl http://localhost/ | grep \"<title>Dependency-Track</title>\"")
      '';
  }
)