# Sources for this configuration: # - https://nixos.org/manual/nixos/stable/#module-security-acme # - https://git.grzb.de/yuri/nix-infra/-/blob/33f2d9e324c2e3a8b1b41c20bce239001bcce9fc/hosts/netbox/nginx.nix # - https://docs.netbox.dev/en/stable/installation/5-http-server/ # - https://github.com/netbox-community/netbox/blob/v3.5.9/contrib/nginx.conf { config, pkgs, ... }: { services.nginx = { enable = true; # So nginx can access the Netbox static files. user = "netbox"; virtualHosts."acme-netbox.ccchh.net" = { default = true; enableACME = true; serverName = "netbox.ccchh.net"; listen = [ { addr = "0.0.0.0"; port = 31820; } ]; }; virtualHosts."netbox.ccchh.net" = { default = true; forceSSL = true; useACMEHost = "netbox.ccchh.net"; listen = [ { addr = "0.0.0.0"; port = 80; } { addr = "0.0.0.0"; port = 443; ssl = true; } ]; locations."/static/" = { alias = "${config.services.netbox.dataDir}/static/"; }; locations."/" = { proxyPass = "http://${config.services.netbox.listenAddress}:${builtins.toString config.services.netbox.port}"; }; extraConfig = '' client_max_body_size 25m; ''; }; }; networking.firewall.allowedTCPPorts = [ 80 443 31820 ]; networking.firewall.allowedUDPPorts = [ 443 ]; }