Unverified Commit 4bc3f439 authored by Alexander Sieg's avatar Alexander Sieg
Browse files

nixos/dependency-track: fix nginx config for frontend

Apparend I fell for some browser cache when implementing this in the
first place. This patch is based on the upstream nginx config.

https://github.com/DependencyTrack/frontend/blob/5f318aca10f85f1f5d7a91d7627883bd506cc48e/docker/etc/nginx/templates/default.conf.template
parent e5a8e186
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>\"")
      '';
  }
)