]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/isabelle/aten_production.nix
Remove duply-backup
[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 {
f8026b6e 15 services.webstats.sites = [ { name = "aten.pro"; } ];
d3452fc5 16 services.phpApplication.apps.isabelle_aten_production = {
717ccfd9
IB
17 websiteEnv = "production";
18 httpdUser = config.services.httpd.Prod.user;
19 httpdGroup = config.services.httpd.Prod.group;
20 httpdWatchFiles = [
d3452fc5 21 config.secrets.fullPaths."websites/isabelle/aten_production"
717ccfd9
IB
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" ];
5400b9b6
IB
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 };
dcac3ec7 40 phpPackage = pkgs.php72;
717ccfd9 41 };
f8026b6e 42
4c4652aa 43 secrets.keys."websites/isabelle/aten_production" = {
717ccfd9 44 user = config.services.httpd.Prod.user;
9f66adf4 45 group = config.services.httpd.Prod.group;
717ccfd9 46 permissions = "0400";
ab8f306d
IB
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 ''
717ccfd9
IB
53 SetEnv APP_ENV "${app.environment}"
54 SetEnv APP_SECRET "${secrets.secret}"
ab8f306d 55 SetEnv DATABASE_URL "${psql_url}"
717ccfd9 56 '';
4c4652aa 57 };
d3452fc5
IB
58 services.websites.env.production.vhostConfs.isabelle_aten_production = {
59 certName = "isabelle";
f8026b6e 60 certMainHost = "aten.pro";
717ccfd9 61 hosts = [ "aten.pro" "www.aten.pro" ];
750fe5a4 62 root = app.webRoot;
717ccfd9
IB
63 extraConfig = [
64 ''
65 <FilesMatch "\.php$">
d3452fc5 66 SetHandler "proxy:unix:${pcfg.phpListenPaths.isabelle_aten_production}|fcgi://localhost"
717ccfd9
IB
67 </FilesMatch>
68
d3452fc5 69 Include ${config.secrets.fullPaths."websites/isabelle/aten_production"}
717ccfd9
IB
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
750fe5a4 79 <Directory ${app.webRoot}>
717ccfd9
IB
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 ];
f8026b6e
IB
88 };
89 };
90}