-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: initial version of Digital Ocean NixOS test server
- Loading branch information
Showing
11 changed files
with
84 additions
and
20 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 |
---|---|---|
|
@@ -16,4 +16,6 @@ in | |
hostname = fqdn; | ||
}; | ||
}; | ||
|
||
oxc.services.acme.enable = true; | ||
} |
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,16 @@ | ||
{ pkgs, lib, config, ... }: { | ||
options.oxc.services.acme = { | ||
enable = lib.mkOption { | ||
type = lib.types.bool; | ||
default = false; | ||
description = "Enable support for ACME LetsEncrypt protocol"; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf config.oxc.services.acme.enable { | ||
security.acme = { | ||
acceptTerms = true; | ||
defaults.email = lib.mkDefault "[email protected]"; | ||
}; | ||
}; | ||
} |
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
_: { | ||
imports = [ | ||
./acme.nix | ||
./flatpak.nix | ||
./tailscale.nix | ||
./tailscale-autoconnect.nix | ||
|
This file was deleted.
Oops, something went wrong.
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,47 @@ | ||
{ ... }: let | ||
webRootHostDir = "/etc/web-server/"; | ||
fqdn = "dotest.carrio.dev"; | ||
in { | ||
security.acme = { | ||
acceptTerms = true; | ||
defaults.email = "[email protected]"; | ||
certs."dotest.carrio.dev" = { | ||
reloadServices = [ "static-web-server" ]; | ||
listenHTTP = ":80"; | ||
group = "www-data"; | ||
# EC is not supported by SWS versions before 2.16.1 | ||
keyType = "rsa4096"; | ||
}; | ||
}; | ||
|
||
# Now we need to open port 80 for the ACME challenge and port 443 for SWS itself | ||
networking.firewall.allowedTCPPorts = [ 80 443 ]; | ||
|
||
# Configure hosted web content | ||
etc.web-server.source = ./webroot; | ||
|
||
# Configure SWS to use the generated TLS certs | ||
services.static-web-server = { | ||
enable = true; | ||
root = webRootHostDir; | ||
listen = "[::]:443"; | ||
configuration = { | ||
general = { | ||
http2 = true; | ||
# Edit the domain name in the file to match your real domain name as configured in the ACME settings | ||
http2-tls-cert = "/var/lib/acme/${fqdn}/fullchain.pem"; | ||
http2-tls-key = "/var/lib/acme/${fqdn}/key.pem"; | ||
# Info here: https://static-web-server.net/features/security-headers/ | ||
# This option is only needed for versions prior to 2.18.0, after which it defaults to true | ||
security-headers = true; | ||
}; | ||
}; | ||
}; | ||
|
||
# Now we need to override some things in the systemd unit files to allow access to those TLS certs, starting with creating a new Linux group: | ||
users.groups.www-data = {}; | ||
|
||
# This strategy can be useful to override other advanced features as-needed | ||
systemd.services.static-web-server.serviceConfig.SupplementaryGroups = pkgs.lib.mkForce [ "" "www-data" ]; | ||
systemd.services.static-web-server.serviceConfig.BindReadOnlyPaths = pkgs.lib.mkForce [webRootHostDir "/var/lib/acme/${fqdn}"]; | ||
} |
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,4 @@ | ||
<html lang="en"> | ||
<head></head> | ||
<body><h1>Test Web Server</h1></body> | ||
</html> |
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 @@ | ||
_: {} |
This file was deleted.
Oops, something went wrong.