Notice: you're looking at a read-only mirror of our Dokuwiki.
This playbook guides you through how to onboard a NixOS machine to have working HTTPS ingress using cloudflared.
cloudflared. You may use nix run nixpkgs#cloudflared -- for your convenience.cloudflared tunnel create {machine}-{for-host-suffix}:nixos-aux-1space for dma.spacenixos-aux-1-space~/.cloudflared/{UUID}.json file. Copy this file's content.cloudflared/{machine}-{for-host-suffix}.json.First, synchronize the secrets into SOPS:
bw sync
just sync-bitwarden-secrets {machine}
For guidance on setting up the Bitwarden CLI bw, see the Bitwarden and SOPS for a NixOS Machine playbook.
Once you've validated that the secret added above is visible in the machine's secrets.bitwarden.yaml, simply copy an existing machine's http.nix into yours. For example, here is nixos-colo-komo-00's:
services.caddy = {
enable = true;
email = "admin@dma.space";
globalConfig = ''
debug
auto_https disable_redirects # handled by cloudflared
'';
logFormat = ''
format console
'';
};
# Use cloudflared tunneling until we have a better internet situation.
# Tunnel secret was manually provisioned.
services.cloudflared = {
enable = true;
# for dma.space zones:
tunnels."nixos-colo-komo-00-space" = {
credentialsFile = "/run/secrets/cloudflared/nixos-colo-komo-00-space.json";
default = "http://localhost:80";
};
};
sops.secrets = {
"cloudflared/nixos-colo-komo-00-space.json".owner = "root";
};
Add the http.nix import into the configuration.nix.
cloudflared tunnel route dns {machine}-{for-host-suffix} {subdomain}.dma.space
For example:
cloudflared tunnel route dns nixos-colo-komo-00-space infra.dma.space