1
Fork 0
mirror of https://github.com/RGBCube/Site synced 2025-08-02 05:57:46 +00:00

Set default port to 4777 and add configureNginx option

This commit is contained in:
RGBCube 2024-01-10 10:09:37 +03:00
parent 798f766943
commit b7db8421fb
No known key found for this signature in database
3 changed files with 31 additions and 3 deletions

View file

@ -111,7 +111,7 @@
port = mkOption {
type = types.port;
default = 8080;
default = 4777;
example = 80;
description = mdDoc ''
Specifies on which port the site service listens for connections.
@ -126,10 +126,32 @@
Specifies the log level that the site service will log stuff with.
'';
};
configureNginx = mkOption {
type = types.bool;
default = false;
description = mdDoc ''
Whether to configure Nginx and set the reverse proxy settings.
'';
};
};
};
config = mkIf cfg.enable {
services.nginx = let
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
urlStripped = removeSuffix "/" (removePrefix "https://" cargoToml.package.homepage);
in mkIf cfg.configureNginx {
enable = true;
recommendedGzipSettings = mkDefault true;
recommendedOptimisation = mkDefault true;
recommendedProxySettings = mkDefault true;
recommendedTlsSettings = mkDefault true;
virtualHosts.${urlStripped}.proxyPass = "http://127.0.0.1:${cfg.port}";
};
systemd.services.site = {
description = "RGBCube's Homepage";
requires = [ "network.target" ];