feat(11): adding reverse proxy to module
This commit is contained in:
parent
e618397eb8
commit
0e67adfcd6
|
@ -43,6 +43,12 @@ let
|
|||
default = "localhost";
|
||||
description = "Host to bind to.";
|
||||
};
|
||||
|
||||
useNginx = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Whether to use Nginx to proxy requests.";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.groups.price-grid-app-group = { };
|
||||
|
@ -51,7 +57,9 @@ let
|
|||
group = "price-grid-app-group";
|
||||
};
|
||||
|
||||
systemd.services.price-grid-app = {
|
||||
systemd.services.price-grid-app =
|
||||
let serverHost = if cfg.useNginx then "localhost" else cfg.host;
|
||||
in {
|
||||
description = "My Java Service";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
|
@ -59,13 +67,22 @@ let
|
|||
startLimitBurst = 10;
|
||||
serviceConfig = {
|
||||
ExecStart =
|
||||
"${pkgs.jdk}/bin/java -jar ${package}/bin/priceGridApp.jar -p ${toString cfg.port} --host ${cfg.host}";
|
||||
"${pkgs.jdk}/bin/java -jar ${package}/bin/priceGridApp.jar -p ${
|
||||
toString cfg.port
|
||||
} --host ${serverHost}";
|
||||
WorkingDirectory = "${package}/bin";
|
||||
Restart = "on-failure";
|
||||
User = "price-grid-app-user";
|
||||
Group = "price-grid-app-group";
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx = lib.mkIf cfg.useNginx {
|
||||
recommendedTlsSettings = true;
|
||||
virtualHosts.${cfg.host} = {
|
||||
locations."/".proxyPass = "http://localhost:${cfg.port}";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
|
|
Loading…
Reference in New Issue