]>
Commit | Line | Data |
---|---|---|
ab8f306d | 1 | { lib, pkgs, config, ... }: |
f8026b6e | 2 | let |
829ef7f1 | 3 | secrets = config.myEnv.websites.isabelle.aten_integration; |
d3452fc5 IB |
4 | app = pkgs.callPackage ./aten_app { |
5 | environment = secrets.environment; | |
6 | varDir = "/var/lib/isabelle_aten_integration"; | |
7 | }; | |
829ef7f1 | 8 | cfg = config.myServices.websites.isabelle.aten_integration; |
717ccfd9 | 9 | pcfg = config.services.phpApplication; |
f8026b6e | 10 | in { |
829ef7f1 | 11 | options.myServices.websites.isabelle.aten_integration.enable = lib.mkEnableOption "enable Aten's website in integration"; |
f8026b6e IB |
12 | |
13 | config = lib.mkIf cfg.enable { | |
d3452fc5 IB |
14 | services.duplyBackup.profiles.isabelle_aten_integration.rootDir = app.varDir; |
15 | services.phpApplication.apps.isabelle_aten_integration = { | |
2e48907d IB |
16 | websiteEnv = "integration"; |
17 | httpdUser = config.services.httpd.Inte.user; | |
18 | httpdGroup = config.services.httpd.Inte.group; | |
717ccfd9 | 19 | httpdWatchFiles = [ |
d3452fc5 | 20 | config.secrets.fullPaths."websites/isabelle/aten_integration" |
717ccfd9 | 21 | ]; |
2e48907d IB |
22 | inherit (app) webRoot varDir; |
23 | inherit app; | |
24 | serviceDeps = [ "postgresql.service" ]; | |
25 | preStartActions = [ | |
26 | "APP_ENV=${app.environment} ./bin/console --env=${app.environment} cache:clear --no-warmup" | |
27 | ]; | |
717ccfd9 | 28 | phpOpenbasedir = [ "/tmp" ]; |
5400b9b6 IB |
29 | phpPool = { |
30 | "php_admin_value[upload_max_filesize]" = "20M"; | |
31 | "php_admin_value[post_max_size]" = "20M"; | |
32 | #"php_admin_flag[log_errors]" = "on"; | |
33 | "pm" = "ondemand"; | |
34 | "pm.max_children" = "5"; | |
35 | "pm.process_idle_timeout" = "60"; | |
36 | }; | |
37 | phpEnv = { | |
d3452fc5 | 38 | SYMFONY_DEBUG_MODE = "\"yes\""; |
5400b9b6 | 39 | }; |
2e48907d IB |
40 | }; |
41 | ||
717ccfd9 | 42 | secrets.keys = [{ |
d3452fc5 | 43 | dest = "websites/isabelle/aten_integration"; |
717ccfd9 | 44 | user = config.services.httpd.Inte.user; |
9f66adf4 | 45 | group = config.services.httpd.Inte.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 IB |
56 | ''; |
57 | }]; | |
d3452fc5 | 58 | services.websites.env.integration.vhostConfs.isabelle_aten_integration = { |
0f71cd76 | 59 | certName = "integration"; |
f8026b6e IB |
60 | addToCerts = true; |
61 | hosts = [ "dev.aten.pro" ]; | |
d3452fc5 | 62 | root = pcfg.webappDirs.isabelle_aten_integration; |
717ccfd9 IB |
63 | extraConfig = [ |
64 | '' | |
65 | <FilesMatch "\.php$"> | |
d3452fc5 | 66 | SetHandler "proxy:unix:${pcfg.phpListenPaths.isabelle_aten_integration}|fcgi://localhost" |
717ccfd9 IB |
67 | </FilesMatch> |
68 | ||
d3452fc5 | 69 | Include ${config.secrets.fullPaths."websites/isabelle/aten_integration"} |
717ccfd9 IB |
70 | |
71 | <Location /> | |
72 | Use LDAPConnect | |
73 | Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu | |
74 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>" | |
75 | </Location> | |
76 | ||
77 | <Location /backend> | |
78 | Use LDAPConnect | |
79 | Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu | |
80 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>" | |
81 | </Location> | |
82 | ||
d3452fc5 | 83 | <Directory ${pcfg.webappDirs.isabelle_aten_integration}> |
717ccfd9 IB |
84 | Options Indexes FollowSymLinks MultiViews Includes |
85 | AllowOverride All | |
86 | Require all granted | |
87 | DirectoryIndex index.php | |
88 | FallbackResource /index.php | |
89 | </Directory> | |
90 | '' | |
91 | ]; | |
f8026b6e IB |
92 | }; |
93 | }; | |
94 | } |