mirror of
https://github.com/RGBCube/Site
synced 2025-08-01 13:37:49 +00:00
Add url option
This commit is contained in:
parent
90d744ac15
commit
81f236e18d
2 changed files with 21 additions and 8 deletions
|
@ -30,6 +30,13 @@ Specifies the log level that the site service will log stuff with.
|
|||
|
||||
Default: info.
|
||||
|
||||
### `services.site.url`
|
||||
|
||||
The url the site is running at.
|
||||
Should not have a protocol speficier or trailing slashes.
|
||||
|
||||
Required.
|
||||
|
||||
### `services.site.configureNginx`
|
||||
|
||||
Whether to configure Nginx and set the reverse proxy settings.
|
||||
|
|
22
flake.nix
22
flake.nix
|
@ -127,6 +127,15 @@
|
|||
'';
|
||||
};
|
||||
|
||||
url = mkOption {
|
||||
type = types.str;
|
||||
example = "rgbcu.be";
|
||||
description = mdDoc ''
|
||||
The url the site is running at.
|
||||
Should not have a protocol speficier or trailing slashes.
|
||||
'';
|
||||
};
|
||||
|
||||
configureNginx = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
|
@ -138,10 +147,7 @@
|
|||
};
|
||||
|
||||
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 {
|
||||
services.nginx = mkIf cfg.configureNginx {
|
||||
enable = true;
|
||||
|
||||
recommendedGzipSettings = mkDefault true;
|
||||
|
@ -149,25 +155,25 @@
|
|||
recommendedProxySettings = mkDefault true;
|
||||
recommendedTlsSettings = mkDefault true;
|
||||
|
||||
virtualHosts.${urlStripped} = {
|
||||
virtualHosts.${cfg.url} = {
|
||||
enableACME = true;
|
||||
forceSSL = true;
|
||||
|
||||
locations."/".proxyPass = "http://localhost:${toString cfg.port}";
|
||||
};
|
||||
|
||||
virtualHosts."www.${urlStripped}" = {
|
||||
virtualHosts."www.${cfg.url}" = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
|
||||
locations."/".extraConfig = ''
|
||||
return 301 https://${urlStripped}$request_uri;
|
||||
return 301 https://${cfg.url}$request_uri;
|
||||
'';
|
||||
};
|
||||
|
||||
virtualHosts._ = {
|
||||
forceSSL = true;
|
||||
useACMEHost = urlStripped;
|
||||
useACMEHost = cfg.url;
|
||||
|
||||
locations."/".extraConfig = ''
|
||||
proxy_pass http://localhost:${toString cfg.port}/404;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue