{ 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"; }; }; extraConfig = '' AddDefaultCharset utf-8 ''; }; }