{ 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"; } ];
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" = "dynamic";
"pm.max_children" = "20";
"pm.start_servers" = "2";
"pm.min_spare_servers" = "1";
"pm.max_spare_servers" = "3";
"php_admin_value[session.save_handler]" = "redis";
"php_admin_value[session.save_path]" = "'unix:///run/redis-php-sessions/redis.sock?persistent=1&prefix=RessourcerieBanon:Production:'";
"php_admin_value[open_basedir]" = "${varDir}:/tmp";
};
phpOptions = config.services.phpfpm.phpOptions + ''
disable_functions = "mail"
'';
phpPackage = pkgs.php72.withExtensions({ enabled, all }: enabled ++ [all.redis]);
};
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" "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
''
];
};
};
}