]>
Commit | Line | Data |
---|---|---|
982dc1fa IB |
1 | { lib, pkgs, config, ... }: |
2 | let | |
305922df IB |
3 | cfg = config.myServices.websites.patrick_fodella.altermondia; |
4 | varDir = "/var/lib/ftp/patrick_fodella/altermondia"; | |
982dc1fa IB |
5 | apacheUser = config.services.httpd.Prod.user; |
6 | apacheGroup = config.services.httpd.Prod.group; | |
792ccef2 IB |
7 | binEnvPaths = [ pkgs.zip ]; |
8 | binEnv = pkgs.buildEnv { paths = binEnvPaths; name = "bin-env";}; | |
982dc1fa | 9 | in { |
305922df | 10 | options.myServices.websites.patrick_fodella.altermondia.enable = lib.mkEnableOption "enable Patrick Fodella Altermondia's website"; |
982dc1fa IB |
11 | |
12 | config = lib.mkIf cfg.enable { | |
305922df | 13 | services.webstats.sites = [ { name = "altermondia.org"; } ]; |
982dc1fa | 14 | |
305922df | 15 | system.activationScripts.patrick_fodella_altermondia = { |
982dc1fa IB |
16 | deps = [ "httpd" ]; |
17 | text = '' | |
305922df | 18 | install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d /var/lib/php/sessions/patrick_fodella_altermondia |
982dc1fa IB |
19 | ''; |
20 | }; | |
305922df IB |
21 | systemd.services.phpfpm-patrick_fodella_altermondia.after = lib.mkAfter [ "mysql.service" ]; |
22 | systemd.services.phpfpm-patrick_fodella_altermondia.wants = [ "mysql.service" ]; | |
23 | services.phpfpm.pools.patrick_fodella_altermondia = { | |
982dc1fa IB |
24 | user = apacheUser; |
25 | group = apacheGroup; | |
26 | settings = { | |
27 | "listen.owner" = apacheUser; | |
28 | "listen.group" = apacheGroup; | |
29 | ||
792ccef2 IB |
30 | "pm" = "dynamic"; |
31 | "pm.max_children" = "20"; | |
32 | "pm.start_servers" = "2"; | |
33 | "pm.min_spare_servers" = "1"; | |
34 | "pm.max_spare_servers" = "3"; | |
982dc1fa | 35 | |
792ccef2 IB |
36 | "env[BIN_ENV]" = "${binEnv}/bin"; |
37 | "php_admin_value[open_basedir]" = "${binEnv}:${builtins.concatStringsSep ":" binEnvPaths}:/var/lib/php/sessions/patrick_fodella_altermondia:${varDir}:/tmp"; | |
305922df | 38 | "php_admin_value[session.save_path]" = "/var/lib/php/sessions/patrick_fodella_altermondia"; |
982dc1fa IB |
39 | }; |
40 | phpOptions = config.services.phpfpm.phpOptions + '' | |
41 | disable_functions = "mail" | |
42 | ''; | |
43 | phpPackage = pkgs.php72; | |
44 | }; | |
45 | services.websites.env.production.modules = [ "proxy_fcgi" ]; | |
305922df | 46 | services.websites.env.production.vhostConfs.patrick_fodella_altermondia = { |
982dc1fa | 47 | certName = "patrick_fodella"; |
305922df IB |
48 | addToCerts = true; |
49 | hosts = ["altermondia.org" "www.altermondia.org" ]; | |
982dc1fa IB |
50 | root = varDir; |
51 | extraConfig = [ | |
52 | '' | |
305922df | 53 | Use Stats altermondia.org |
982dc1fa IB |
54 | |
55 | RewriteEngine on | |
305922df IB |
56 | RewriteCond "%{HTTP_HOST}" "!^altermondia\.org$" [NC] |
57 | RewriteRule ^(.+)$ https://altermondia.org$1 [R=302,L] | |
982dc1fa IB |
58 | |
59 | <FilesMatch "\.php$"> | |
305922df | 60 | SetHandler "proxy:unix:${config.services.phpfpm.pools.patrick_fodella_altermondia.socket}|fcgi://localhost" |
982dc1fa IB |
61 | </FilesMatch> |
62 | ||
63 | <Location /xmlrpc.php> | |
64 | AllowOverride None | |
65 | Require all denied | |
66 | </Location> | |
67 | <Directory ${varDir}> | |
68 | DirectoryIndex index.php index.htm index.html | |
69 | Options Indexes FollowSymLinks MultiViews Includes | |
70 | AllowOverride all | |
71 | Require all granted | |
72 | </Directory> | |
73 | '' | |
74 | ]; | |
75 | }; | |
76 | }; | |
77 | } | |
305922df | 78 |