]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/isabelle/aten_production.nix
e34d65913e86d6b6410f0ec7c71df16b8dcf5782
[perso/Immae/Config/Nix.git] / modules / private / websites / isabelle / aten_production.nix
1 { lib, pkgs, config, ... }:
2 let
3 secrets = config.myEnv.websites.isabelle.aten_production;
4 app = pkgs.callPackage ./aten_app {
5 environment = secrets.environment;
6 varDir = "/var/lib/isabelle_aten_production";
7 };
8 cfg = config.myServices.websites.isabelle.aten_production;
9 pcfg = config.services.phpApplication;
10 in {
11 options.myServices.websites.isabelle.aten_production.enable = lib.mkEnableOption "enable Aten's website in production";
12
13 config = lib.mkIf cfg.enable {
14 services.duplyBackup.profiles.isabelle_aten_production.rootDir = app.varDir;
15 services.webstats.sites = [ { name = "aten.pro"; } ];
16 services.phpApplication.apps.isabelle_aten_production = {
17 websiteEnv = "production";
18 httpdUser = config.services.httpd.Prod.user;
19 httpdGroup = config.services.httpd.Prod.group;
20 httpdWatchFiles = [
21 config.secrets.fullPaths."websites/isabelle/aten_production"
22 ];
23 inherit (app) webRoot varDir;
24 inherit app;
25 serviceDeps = [ "postgresql.service" ];
26 preStartActions = [
27 "APP_ENV=${app.environment} ./bin/console --env=${app.environment} cache:clear --no-warmup"
28 ];
29 phpOpenbasedir = [ "/tmp" ];
30 phpPool = {
31 "php_admin_value[upload_max_filesize]" = "20M";
32 "php_admin_value[post_max_size]" = "20M";
33 #"php_admin_flag[log_errors]" = "on";
34 "pm" = "dynamic";
35 "pm.max_children" = "20";
36 "pm.start_servers" = "2";
37 "pm.min_spare_servers" = "1";
38 "pm.max_spare_servers" = "3";
39 };
40 };
41
42 secrets.keys = [{
43 dest = "websites/isabelle/aten_production";
44 user = config.services.httpd.Prod.user;
45 group = config.services.httpd.Prod.group;
46 permissions = "0400";
47 text = let
48 # cf:
49 # https://secure.php.net/manual/fr/function.parse-url.php
50 # vendor/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php#parseDatabaseUrlQuery
51 psql_url = with secrets.postgresql; "pdo-pgsql://${user}:${password}@invalid:${port}/${database}?host=${socket}";
52 in ''
53 SetEnv APP_ENV "${app.environment}"
54 SetEnv APP_SECRET "${secrets.secret}"
55 SetEnv DATABASE_URL "${psql_url}"
56 '';
57 }];
58 services.websites.env.production.vhostConfs.isabelle_aten_production = {
59 certName = "isabelle";
60 certMainHost = "aten.pro";
61 hosts = [ "aten.pro" "www.aten.pro" ];
62 root = pcfg.webappDirs.isabelle_aten_production;
63 extraConfig = [
64 ''
65 <FilesMatch "\.php$">
66 SetHandler "proxy:unix:${pcfg.phpListenPaths.isabelle_aten_production}|fcgi://localhost"
67 </FilesMatch>
68
69 Include ${config.secrets.fullPaths."websites/isabelle/aten_production"}
70
71 Use Stats aten.pro
72
73 <Location /backend>
74 Use LDAPConnect
75 Require ldap-group cn=aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
76 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
77 </Location>
78
79 <Directory ${pcfg.webappDirs.isabelle_aten_production}>
80 Options Indexes FollowSymLinks MultiViews Includes
81 AllowOverride All
82 Require all granted
83 DirectoryIndex index.php
84 FallbackResource /index.php
85 </Directory>
86 ''
87 ];
88 };
89 };
90 }