diff --git a/hosts/web-arm/modules/web/stack.nix b/hosts/web-arm/modules/web/stack.nix index e588cf3..8abe596 100644 --- a/hosts/web-arm/modules/web/stack.nix +++ b/hosts/web-arm/modules/web/stack.nix @@ -53,6 +53,7 @@ let enableMysql = mkEnableOption (lib.mdDoc "MySQL Database"); enableDefaultLocations = mkEnableOption (lib.mdDoc "Create default nginx location directives") // { default = true; }; + enablePhp = mkEnableOption (lib.mdDoc "PHP-FPM support") // { default = true; }; authorizedKeys = mkOption { type = types.listOf types.str; @@ -138,12 +139,12 @@ in BindPaths = "BindPaths=/var/www/${domain}:/var/www/${domain}"; }; } - ) cfg.instances; + ) (lib.filterAttrs (name: opts: opts.enablePhp) cfg.instances); services.phpfpm.pools = mapAttrs' (instance: instanceOpts: let domain = if instanceOpts.domain != null then instanceOpts.domain else instance; - user = if instanceOpts.user != null + user = if instanceOpts.user != null then instanceOps.user else builtins.replaceStrings ["." "-"] ["_" "_"] domain; in @@ -166,7 +167,7 @@ in phpPackage = instanceOpts.phpPackage; phpEnv."PATH" = pkgs.lib.makeBinPath [ instanceOpts.phpPackage ]; } - ) cfg.instances; + ) (lib.filterAttrs (name: opts: opts.enablePhp) cfg.instances); }; @@ -216,7 +217,7 @@ in ''; # Cache Media: images, icons, video, audio, HTC - "~* \\.(?:jpg|jpeg|gif|png|webp|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|woff2)$".extraConfig = '' + "~* \\.(?:css|js|jpg|jpeg|gif|png|webp|avif|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|woff2)$".extraConfig = '' expires 1y; access_log off; add_header Cache-Control "public"; @@ -228,19 +229,12 @@ in add_header Cache-Control "public"; ''; - # Cache CSS, Javascript, Images, Icons, Video, Audio, HTC, Fonts - "~* \\.(?:css|js|jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|woff2)$".extraConfig = '' - expires 1y; - access_log off; - add_header Cache-Control "public"; - ''; - "/".extraConfig = '' index index.php index.html; try_files $uri $uri/ /index.php$is_args$args; ''; }) - { + (mkIf instanceOpts.enablePhp { "~ [^/]\\.php(/|$)".extraConfig = '' fastcgi_split_path_info ^(.+?\.php)(/.*)$; if (!-f $document_root$fastcgi_script_name) { @@ -256,7 +250,7 @@ in fastcgi_pass unix:${config.services.phpfpm.pools."${domain}".socket}; fastcgi_index index.php; ''; - } + }) ]; extraConfig = instanceOpts.extraConfig; diff --git a/hosts/web-arm/sites/cloonar.com.nix b/hosts/web-arm/sites/cloonar.com.nix index 2fd691c..e11af1a 100644 --- a/hosts/web-arm/sites/cloonar.com.nix +++ b/hosts/web-arm/sites/cloonar.com.nix @@ -5,6 +5,8 @@ let in { services.webstack.instances."${domain}" = { + enablePhp = false; + authorizedKeys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOXKR0AQdP1zn6pL2yjGA/eo9F5Ah2u6+Y5dIk8wR5/I" ]; @@ -67,7 +69,5 @@ in { add_header Pragma "public"; add_header Cache-Control "public"; ''; - - phpPackage = pkgs.php; }; } diff --git a/hosts/web-arm/sites/cloonar.dev.nix b/hosts/web-arm/sites/cloonar.dev.nix index 2a097be..7e02e08 100644 --- a/hosts/web-arm/sites/cloonar.dev.nix +++ b/hosts/web-arm/sites/cloonar.dev.nix @@ -5,6 +5,8 @@ let in { services.webstack.instances."${domain}" = { + enablePhp = false; + authorizedKeys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINrxGbJ8vqOLMySIst+e2Qq06bPLPh+7fmPRM27kMBgC" ]; @@ -67,7 +69,5 @@ in { add_header Pragma "public"; add_header Cache-Control "public"; ''; - - phpPackage = pkgs.php; }; }