debug stuff

This commit is contained in:
efim 2023-08-06 14:54:17 +00:00
parent 24b42352b3
commit f164fff56c
1 changed files with 42 additions and 42 deletions

View File

@ -73,50 +73,50 @@
description = "Whether to use Nginx to proxy requests."; description = "Whether to use Nginx to proxy requests.";
}; };
}; };
config = lib.mkIf cfg.enable { # config = lib.mkIf cfg.enable {
users.groups."${backendName}-group" = { }; # users.groups."${backendName}-group" = { };
users.users."${backendName}-user" = { # users.users."${backendName}-user" = {
isSystemUser = true; # isSystemUser = true;
group = "${backendName}-group"; # group = "${backendName}-group";
}; # };
systemd.services.${backendName} = # systemd.services.${backendName} =
let serverHost = if cfg.useNginx then "localhost" else cfg.host; # let serverHost = if cfg.useNginx then "localhost" else cfg.host;
in { # in {
description = "Exercise app ${backendName}"; # description = "Exercise app ${backendName}";
wantedBy = [ "multi-user.target" ]; # wantedBy = [ "multi-user.target" ];
after = [ "network.target" ]; # after = [ "network.target" ];
startLimitIntervalSec = 30; # startLimitIntervalSec = 30;
startLimitBurst = 10; # startLimitBurst = 10;
serviceConfig = { # serviceConfig = {
ExecStart = # ExecStart =
"${pkgs.jdk}/bin/java -jar ${backendPackage}/bin/${backendName}.jar -p ${ # "${pkgs.jdk}/bin/java -jar ${backendPackage}/bin/${backendName}.jar -p ${
toString cfg.port # toString cfg.port
} --host ${serverHost}"; # } --host ${serverHost}";
WorkingDirectory = "${backendPackage}/bin"; # WorkingDirectory = "${backendPackage}/bin";
Restart = "on-failure"; # Restart = "on-failure";
User = "${backendName}-user"; # User = "${backendName}-user";
Group = "${backendName}-group"; # Group = "${backendName}-group";
}; # };
}; # };
# this is only backend. Front end still configured and installed separately. # # this is only backend. Front end still configured and installed separately.
services.nginx.virtualHosts.${cfg.host}.locations."/api" = { # services.nginx.virtualHosts.${cfg.host}.locations."/api" = {
proxyPass = "http://127.0.0.1:${toString cfg.port}"; # proxyPass = "http://127.0.0.1:${toString cfg.port}";
# this is config for websocket # # this is config for websocket
extraConfig = '' # extraConfig = ''
rewrite ^/api/(.*)$ /$1 break; # rewrite ^/api/(.*)$ /$1 break;
proxy_set_header Host $host; # proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr; # proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; # proxy_set_header X-Forwarded-Proto $scheme;
# Add the following lines for WebSocket support # # Add the following lines for WebSocket support
proxy_http_version 1.1; # proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; # proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade"; # proxy_set_header Connection "upgrade";
''; # '';
}; # };
}; # };
}; };
}); });
# see https://serokell.io/blog/practical-nix-flakes # see https://serokell.io/blog/practical-nix-flakes