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