Summary Files Commits Branches @commit @diff @stats
path: root / modules / server / httpd.nix
diff options
context:
space:
mode:
1 files changed, 31 insertions, 0 deletions
-rw-r--r--modules/server/httpd.nix31
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";
+ };
+ };
+ };
+}