mirror of
https://github.com/nmasur/dotfiles
synced 2025-04-24 15:02:24 +00:00
Compare commits
3 Commits
f757e4a894
...
1b7e4687e4
Author | SHA1 | Date | |
---|---|---|---|
|
1b7e4687e4 | ||
|
9f33371daf | ||
|
bbc529287d |
@ -239,6 +239,7 @@
|
||||
influxdb = "influxdb.${baseName}";
|
||||
irc = "irc.${baseName}";
|
||||
metrics = "metrics.${baseName}";
|
||||
minecraft = "minecraft.${baseName}";
|
||||
prometheus = "prom.${baseName}";
|
||||
paperless = "paper.${baseName}";
|
||||
secrets = "vault.${baseName}";
|
||||
|
@ -71,7 +71,7 @@ provider "vultr" {
|
||||
|
||||
resource "vultr_iso_private" "image" {
|
||||
# url = "https://${var.cloudflare_account_id}.r2.cloudflarestorage.com/${data.aws_s3_bucket.images.id}/${aws_s3_object.image.key}"
|
||||
url = "https://arrow.images.masu.rs/arrow.iso"
|
||||
url = "https://arrow-images.masu.rs/arrow.iso"
|
||||
}
|
||||
|
||||
resource "vultr_instance" "arrow" {
|
||||
|
@ -75,6 +75,10 @@
|
||||
type = lib.types.str;
|
||||
description = "Hostname for metrics server.";
|
||||
};
|
||||
minecraft = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Hostname for Minecraft server.";
|
||||
};
|
||||
paperless = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "Hostname for document server (paperless-ngx).";
|
||||
|
@ -44,6 +44,8 @@ in {
|
||||
|
||||
networking.firewall.allowedTCPPorts = [ publicPort ];
|
||||
|
||||
cloudflare.noProxyDomains = [ config.hostnames.minecraft ];
|
||||
|
||||
## Automatically start and stop Minecraft server based on player connections
|
||||
|
||||
# Adapted shamelessly from:
|
||||
|
@ -46,6 +46,12 @@ in {
|
||||
|
||||
options.cloudflare.enable = lib.mkEnableOption "Use Cloudflare.";
|
||||
|
||||
options.cloudflare.noProxyDomains = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
description = "Domains to use for dyndns without CDN proxying.";
|
||||
default = [ ];
|
||||
};
|
||||
|
||||
config = lib.mkIf config.cloudflare.enable {
|
||||
|
||||
# Forces Caddy to error if coming from a non-Cloudflare IP
|
||||
@ -95,6 +101,7 @@ in {
|
||||
services.cloudflare-dyndns = {
|
||||
enable = true;
|
||||
proxied = true;
|
||||
deleteMissing = true;
|
||||
apiTokenFile = config.secrets.cloudflare-api.dest;
|
||||
};
|
||||
|
||||
@ -104,5 +111,39 @@ in {
|
||||
requires = [ "cloudflare-api-secret.service" ];
|
||||
};
|
||||
|
||||
# Run a second copy of dyn-dns for non-proxied domains
|
||||
# Adapted from: https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/services/networking/cloudflare-dyndns.nix
|
||||
systemd.services.cloudflare-dyndns-noproxy = {
|
||||
description = "CloudFlare Dynamic DNS Client (no proxy)";
|
||||
after = [ "network.target" "cloudflare-api-secret.service" ];
|
||||
requires = [ "cloudflare-api-secret.service" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
startAt = "*:0/5";
|
||||
|
||||
environment = {
|
||||
CLOUDFLARE_DOMAINS = toString config.cloudflare.noProxyDomains;
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
DynamicUser = true;
|
||||
StateDirectory = "cloudflare-dyndns-noproxy";
|
||||
EnvironmentFile = config.services.cloudflare-dyndns.apiTokenFile;
|
||||
ExecStart = let
|
||||
args = [ "--cache-file /var/lib/cloudflare-dyndns-noproxy/ip.cache" ]
|
||||
++ (if config.services.cloudflare-dyndns.ipv4 then
|
||||
[ "-4" ]
|
||||
else
|
||||
[ "-no-4" ]) ++ (if config.services.cloudflare-dyndns.ipv6 then
|
||||
[ "-6" ]
|
||||
else
|
||||
[ "-no-6" ])
|
||||
++ lib.optional config.services.cloudflare-dyndns.deleteMissing
|
||||
"--delete-missing";
|
||||
|
||||
in "${pkgs.cloudflare-dyndns}/bin/cloudflare-dyndns ${toString args}";
|
||||
};
|
||||
};
|
||||
|
||||
};
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user