1.7 KiB
1.7 KiB
Playbook: Add a Server Module with mkserver
- Name: Add a reverse-proxied server module
- Purpose: Stand up a server using
modules/factories/mkserver.nixwith correct proxy and host routing. - Prerequisites: Target host must have
my.enableProxy = trueand container support if needed; confirmmy.secureHostfor secrets. - Inputs: Service name, desired subdomain, port, proxy type (standard/fix/private), cron needs, secrets/env vars.
- Steps:
- Create
modules/servers/<name>.nixand importmkserveroptions to defineenable,enableProxy,port,host,hostName,url,ip,enableSocket, andcertPathas needed. - Default host routing uses
my.mainServerandmy.ips; overridehostName/iponly when the service must live elsewhere. - For reverse proxy behavior, select helper from
parts/core.nix:proxyReverse(standard),proxyReverseFix(preserve host headers/websockets), orproxyReversePrivate(mutual TLS). - Place secrets/env references in the appropriate file from the secrets map and guard with
lib.mkIf config.my.secureHost. - Enable the service toggle in
hosts/<host>/toggles.nixunderservers(andenableProxyif not already set); add any firewall/static ports needed.
- Create
- Validation:
- Service resolves to the expected URL and IP per
my.ipsandmy.mainServer. - Proxy helper matches the protocol needs; SSL settings align with cert sources.
- Secrets load only on secure hosts; firewall assertions pass.
- Service resolves to the expected URL and IP per
- Outputs: New server module with mkserver options and updated host toggles/firewall settings.
- References:
docs/constitution.md(Main server and proxies, Secrets Map),docs/reference/index.md(Proxy rules, Module Directories, Secrets Map, Hosts and Roles)