feat: web stack make php optional
This commit is contained in:
@@ -53,6 +53,7 @@ let
|
|||||||
|
|
||||||
enableMysql = mkEnableOption (lib.mdDoc "MySQL Database");
|
enableMysql = mkEnableOption (lib.mdDoc "MySQL Database");
|
||||||
enableDefaultLocations = mkEnableOption (lib.mdDoc "Create default nginx location directives") // { default = true; };
|
enableDefaultLocations = mkEnableOption (lib.mdDoc "Create default nginx location directives") // { default = true; };
|
||||||
|
enablePhp = mkEnableOption (lib.mdDoc "PHP-FPM support") // { default = true; };
|
||||||
|
|
||||||
authorizedKeys = mkOption {
|
authorizedKeys = mkOption {
|
||||||
type = types.listOf types.str;
|
type = types.listOf types.str;
|
||||||
@@ -138,7 +139,7 @@ in
|
|||||||
BindPaths = "BindPaths=/var/www/${domain}:/var/www/${domain}";
|
BindPaths = "BindPaths=/var/www/${domain}:/var/www/${domain}";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
) cfg.instances;
|
) (lib.filterAttrs (name: opts: opts.enablePhp) cfg.instances);
|
||||||
|
|
||||||
services.phpfpm.pools = mapAttrs' (instance: instanceOpts:
|
services.phpfpm.pools = mapAttrs' (instance: instanceOpts:
|
||||||
let
|
let
|
||||||
@@ -166,7 +167,7 @@ in
|
|||||||
phpPackage = instanceOpts.phpPackage;
|
phpPackage = instanceOpts.phpPackage;
|
||||||
phpEnv."PATH" = pkgs.lib.makeBinPath [ 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
|
# 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;
|
expires 1y;
|
||||||
access_log off;
|
access_log off;
|
||||||
add_header Cache-Control "public";
|
add_header Cache-Control "public";
|
||||||
@@ -228,19 +229,12 @@ in
|
|||||||
add_header Cache-Control "public";
|
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 = ''
|
"/".extraConfig = ''
|
||||||
index index.php index.html;
|
index index.php index.html;
|
||||||
try_files $uri $uri/ /index.php$is_args$args;
|
try_files $uri $uri/ /index.php$is_args$args;
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
{
|
(mkIf instanceOpts.enablePhp {
|
||||||
"~ [^/]\\.php(/|$)".extraConfig = ''
|
"~ [^/]\\.php(/|$)".extraConfig = ''
|
||||||
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
|
||||||
if (!-f $document_root$fastcgi_script_name) {
|
if (!-f $document_root$fastcgi_script_name) {
|
||||||
@@ -256,7 +250,7 @@ in
|
|||||||
fastcgi_pass unix:${config.services.phpfpm.pools."${domain}".socket};
|
fastcgi_pass unix:${config.services.phpfpm.pools."${domain}".socket};
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
'';
|
'';
|
||||||
}
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
extraConfig = instanceOpts.extraConfig;
|
extraConfig = instanceOpts.extraConfig;
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ let
|
|||||||
in {
|
in {
|
||||||
|
|
||||||
services.webstack.instances."${domain}" = {
|
services.webstack.instances."${domain}" = {
|
||||||
|
enablePhp = false;
|
||||||
|
|
||||||
authorizedKeys = [
|
authorizedKeys = [
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOXKR0AQdP1zn6pL2yjGA/eo9F5Ah2u6+Y5dIk8wR5/I"
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOXKR0AQdP1zn6pL2yjGA/eo9F5Ah2u6+Y5dIk8wR5/I"
|
||||||
];
|
];
|
||||||
@@ -67,7 +69,5 @@ in {
|
|||||||
add_header Pragma "public";
|
add_header Pragma "public";
|
||||||
add_header Cache-Control "public";
|
add_header Cache-Control "public";
|
||||||
'';
|
'';
|
||||||
|
|
||||||
phpPackage = pkgs.php;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ let
|
|||||||
in {
|
in {
|
||||||
|
|
||||||
services.webstack.instances."${domain}" = {
|
services.webstack.instances."${domain}" = {
|
||||||
|
enablePhp = false;
|
||||||
|
|
||||||
authorizedKeys = [
|
authorizedKeys = [
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINrxGbJ8vqOLMySIst+e2Qq06bPLPh+7fmPRM27kMBgC"
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINrxGbJ8vqOLMySIst+e2Qq06bPLPh+7fmPRM27kMBgC"
|
||||||
];
|
];
|
||||||
@@ -67,7 +69,5 @@ in {
|
|||||||
add_header Pragma "public";
|
add_header Pragma "public";
|
||||||
add_header Cache-Control "public";
|
add_header Cache-Control "public";
|
||||||
'';
|
'';
|
||||||
|
|
||||||
phpPackage = pkgs.php;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user