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