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