From 5f5f3cc1377ac45ad5193e77fbe465f96603a0a4 Mon Sep 17 00:00:00 2001 From: Syndamia Date: Tue, 1 Jul 2025 18:28:13 +0300 Subject: feat(modules/server): Add minimal dnsmasq and httpd modules --- modules/server/dnsmasq.nix | 19 +++++++++++++++++++ modules/server/httpd.nix | 31 +++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 modules/server/dnsmasq.nix create mode 100644 modules/server/httpd.nix (limited to 'modules/server') diff --git a/modules/server/dnsmasq.nix b/modules/server/dnsmasq.nix new file mode 100644 index 0000000..4461e4f --- /dev/null +++ b/modules/server/dnsmasq.nix @@ -0,0 +1,19 @@ +{ + networking.firewall = { + allowedTCPPorts = [ 53 ]; + allowedUDPPorts = [ 53 ]; + }; + services.dnsmasq = { + enable = true; + alwaysKeepRunning = true; + settings = { + addn-hosts = "/etc/hosts"; + server = [ + "1.1.1.1" + "1.0.0.1" + "8.8.8.8" + "8.8.4.4" + ]; + }; + }; +} diff --git a/modules/server/httpd.nix b/modules/server/httpd.nix new file mode 100644 index 0000000..b05207a --- /dev/null +++ b/modules/server/httpd.nix @@ -0,0 +1,31 @@ +{ pkgs, ... }: { + environment.systemPackages = with pkgs; [ + apacheHttpd + ]; + + networking.firewall = { + allowedTCPPorts = [ 80 443 ]; + allowedUDPPorts = [ 80 443 ]; + }; + + services.httpd = { + enable = true; + extraModules = [ "ssl" ]; + virtualHosts = { + "00000_http.com" = { + listen = [ { port = 80; } ]; + documentRoot = "/var/www/default"; + }; + "00000_https.com" = { + onlySSL = true; + extraConfig = '' + RewriteEngine On + RewriteRule ^ http://%{HTTP_HOST}%{REQUEST_URI} [R=302,L,QSA] + ''; + # Thanks https://discourse.nixos.org/t/where-can-i-get-snakeoil-certificates/14628/4 + sslServerCert = "${pkgs.path}/nixos/tests/common/acme/server/acme.test.cert.pem"; + sslServerKey = "${pkgs.path}/nixos/tests/common/acme/server/acme.test.key.pem"; + }; + }; + }; +} -- cgit v1.3.1-23-gd82d