1
Fork 0
mirror of https://github.com/RGBCube/Site synced 2025-08-01 13:37:49 +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

@ -22,7 +22,7 @@ Default: false.
Specifies on which port the site service listens for connections. Specifies on which port the site service listens for connections.
Default: 8080. Default: 4777.
### `services.site.logLevel` ### `services.site.logLevel`
@ -30,6 +30,12 @@ Specifies the log level that the site service will log stuff with.
Default: info. Default: info.
### `services.site.configureNginx`
Whether to configure Nginx and set the reverse proxy settings.
Default: false.
## License ## License
All the markdown files under the `src/` directory are licensed All the markdown files under the `src/` directory are licensed

View file

@ -111,7 +111,7 @@
port = mkOption { port = mkOption {
type = types.port; type = types.port;
default = 8080; default = 4777;
example = 80; example = 80;
description = mdDoc '' description = mdDoc ''
Specifies on which port the site service listens for connections. 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. 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 { 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 = { systemd.services.site = {
description = "RGBCube's Homepage"; description = "RGBCube's Homepage";
requires = [ "network.target" ]; requires = [ "network.target" ];

View file

@ -18,7 +18,7 @@ use tower_http::trace::TraceLayer;
#[command(author, version, about)] #[command(author, version, about)]
struct Cli { struct Cli {
/// The port to listen for connections on /// The port to listen for connections on
#[arg(long, default_value = "8080")] #[arg(long, default_value = "4777")]
port: u16, port: u16,
/// The log level to log stuff with /// The log level to log stuff with
#[arg(long, default_value = "info")] #[arg(long, default_value = "info")]