-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: trying out nginx configurations
- Loading branch information
Showing
7 changed files
with
123 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ config | ||
, lib | ||
, pkgs | ||
, inputs | ||
, ... | ||
}: | ||
let | ||
fallbacks = config: | ||
let | ||
ipv4 = if config.network.ipv4.address != null then [ "http://${config.network.ipv4.address}" ] else [ ]; | ||
ipv6 = if config.network.ipv6.address != null then [ "http://${config.network.ipv6.address}" ] else [ ]; | ||
in | ||
[ | ||
"kolyma.uz" | ||
"www.kolyma.uz" | ||
"niggerlicious.uz" | ||
"www.niggerlicious.uz" | ||
] | ||
++ ipv4 | ||
++ ipv6 | ||
++ config.services.www.alias; | ||
|
||
default = { | ||
# Configure Nginx | ||
services.nginx = { | ||
# Enable the Nginx web server | ||
enable = true; | ||
|
||
# Default virtual host | ||
virtualHosts = { | ||
"kolyma.uz" = { | ||
forceSSL = true; | ||
enableACME = true; | ||
serverAliases = fallbacks config; | ||
root = "${pkgs.personal.gate}/www"; | ||
}; | ||
}; | ||
}; | ||
|
||
# Accepting ACME Terms | ||
security.acme = { | ||
acceptTerms = true; | ||
defaults = { | ||
email = "admin@kolyma.uz"; | ||
}; | ||
}; | ||
|
||
# Ensure the firewall allows HTTP and HTTPS traffic | ||
networking.firewall.allowedTCPPorts = [ 80 443 ]; | ||
networking.firewall.allowedUDPPorts = [ 80 443 ]; | ||
}; | ||
|
||
extra = { | ||
# Extra configurations for Nginx | ||
services.nginx = { | ||
# User provided hosts | ||
virtualHosts = config.services.www.hosts; | ||
}; | ||
}; | ||
|
||
cfg = lib.mkMerge [ | ||
default | ||
extra | ||
]; | ||
in | ||
{ | ||
options = { | ||
services.www = { | ||
enable = lib.mkOption { | ||
type = lib.types.bool; | ||
default = false; | ||
description = "Enable the web server/proxy"; | ||
}; | ||
|
||
alias = lib.mkOption { | ||
type = lib.types.listOf lib.types.str; | ||
default = [ ]; | ||
description = "List of extra aliases to host."; | ||
}; | ||
|
||
hosts = lib.mkOption { | ||
type = lib.types.attrsOf lib.types.anything; | ||
default = { }; | ||
description = "List of hosted container instances."; | ||
}; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf config.services.www.enable cfg; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,5 +10,8 @@ | |
|
||
# Web server & proxy virtual hosts via caddy | ||
./caddy.nix | ||
|
||
# GitLab server | ||
./gitlab.nix | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ outputs, pkgs, ... }: { | ||
services.gitlab = { | ||
enable = true; | ||
databasePasswordFile = pkgs.writeText "dbPassword" "zgvcyfwsxzcwr85l"; | ||
initialRootPasswordFile = pkgs.writeText "rootPassword" "dakqdvp4ovhksxer"; | ||
secrets = { | ||
secretFile = pkgs.writeText "secret" "xlHvN7tfexeTbFVHbkVKESQbyTZXG9v1TZ1me9Txa4GtxUMeKI"; | ||
otpFile = pkgs.writeText "otpsecret" "ME5h5Wh4NUjlvSqIM2tbBs9v44BVJb0BMrpGjOInGGJeJ6U7rE"; | ||
dbFile = pkgs.writeText "dbsecret" "HNWvNMIv9APPn9jl7K02Jh7EEpqtmPPrfgF7o0wUx4IrbmOFww"; | ||
jwsFile = pkgs.runCommand "oidcKeyBase" { } "${pkgs.openssl}/bin/openssl genrsa 2048 > $out"; | ||
}; | ||
}; | ||
|
||
services.nginx = { | ||
enable = true; | ||
recommendedProxySettings = true; | ||
virtualHosts = { | ||
localhost = { | ||
locations."/".proxyPass = "http://unix:/run/gitlab/gitlab-workhorse.socket"; | ||
}; | ||
}; | ||
}; | ||
|
||
systemd.services.gitlab-backup.environment.BACKUP = "dump"; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,6 @@ | |
./container.nix | ||
|
||
# Web server & proxy virtual hosts via caddy | ||
./caddy.nix | ||
./www.nix | ||
]; | ||
} |
2 changes: 1 addition & 1 deletion
2
nixos/kolyma-4/services/caddy.nix → nixos/kolyma-4/services/www.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters