{ lib, pkgs, config, ... }:
let
cfg = config.myServices.websites.ressourcerie_banon.production;
varDir = "/var/lib/ftp/ressourcerie_banon";
apacheUser = config.services.httpd.Prod.user;
apacheGroup = config.services.httpd.Prod.group;
in {
options.myServices.websites.ressourcerie_banon.production.enable = lib.mkEnableOption "enable Ressourcerie Banon's website";
config = lib.mkIf cfg.enable {
services.webstats.sites = [ { name = "ressourcerie-banon.org"; } ];
system.activationScripts.ressourcerie_banon = {
deps = [ "httpd" ];
text = ''
install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/ressourcerie_banon
'';
};
systemd.services.phpfpm-ressourcerie_banon.after = lib.mkAfter [ "mysql.service" ];
systemd.services.phpfpm-ressourcerie_banon.wants = [ "mysql.service" ];
services.phpfpm.pools.ressourcerie_banon = {
user = apacheUser;
group = apacheGroup;
settings = {
"listen.owner" = apacheUser;
"listen.group" = apacheGroup;
"pm" = "ondemand";
"pm.max_children" = "5";
"pm.process_idle_timeout" = "60";
"php_admin_value[open_basedir]" = "/var/lib/php/sessions/ressourcerie_banon:${varDir}:/tmp";
"php_admin_value[session.save_path]" = "/var/lib/php/sessions/ressourcerie_banon";
};
phpOptions = config.services.phpfpm.phpOptions + ''
disable_functions = "mail"
'';
phpPackage = pkgs.php72;
};
services.websites.env.production.modules = [ "proxy_fcgi" ];
services.websites.env.production.vhostConfs.ressourcerie_banon = {
certName = "ressourcerie_banon";
certMainHost = "ressourcerie-banon.org";
hosts = ["ressourcerie-banon.org" "www.ressourcerie-banon.org" "ressourcerie-sault.org" "www.ressourcerie-sault.org" "le-garage-autonome.org"
"www.le-garage-autonome.org"];
root = varDir;
extraConfig = [
''
Use Stats ressourcerie-banon.org
RewriteEngine on
RewriteCond "%{HTTP_HOST}" "!^ressourcerie-banon\.org$" [NC]
RewriteRule ^(.+)$ https://ressourcerie-banon.org$1 [R=302,L]
SetHandler "proxy:unix:${config.services.phpfpm.pools.ressourcerie_banon.socket}|fcgi://localhost"
DirectoryIndex index.php index.htm index.html
Options Indexes FollowSymLinks MultiViews Includes
AllowOverride all
Require all granted
''
];
};
};
}