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