]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/piedsjaloux/integration.nix
Move integration php applications to dedicated module
[perso/Immae/Config/Nix.git] / modules / private / websites / piedsjaloux / integration.nix
CommitLineData
f8026b6e
IB
1{ lib, pkgs, config, myconfig, ... }:
2let
9f66adf4
IB
3 secrets = myconfig.env.websites.piedsjaloux.integration;
4 app = pkgs.webapps.piedsjaloux.override { environment = secrets.environment; };
f8026b6e 5 cfg = config.myServices.websites.piedsjaloux.integration;
9f66adf4 6 pcfg = config.services.phpApplication;
f8026b6e
IB
7in {
8 options.myServices.websites.piedsjaloux.integration.enable = lib.mkEnableOption "enable PiedsJaloux's website in integration";
9
10 config = lib.mkIf cfg.enable {
9f66adf4
IB
11 services.phpApplication.apps.piedsjaloux_dev = {
12 websiteEnv = "integration";
13 httpdUser = config.services.httpd.Inte.user;
14 httpdGroup = config.services.httpd.Inte.group;
15 inherit (app) webRoot varDir;
16 varDirPaths = {
17 "tmp" = "0700";
18 };
19 inherit app;
20 serviceDeps = [ "mysql.service" ];
21 preStartActions = [
22 "./bin/console --env=${app.environment} cache:clear --no-warmup"
23 ];
24 phpOpenbasedir = [ "/tmp" ];
25 phpPool = ''
26 php_admin_value[upload_max_filesize] = 20M
27 php_admin_value[post_max_size] = 20M
28 ;php_admin_flag[log_errors] = on
29 env[PATH] = ${lib.makeBinPath [ pkgs.apg pkgs.unzip ]}
30 pm = ondemand
31 pm.max_children = 5
32 pm.process_idle_timeout = 60
33 env[SYMFONY_DEBUG_MODE] = "yes"
34 '';
35 phpWatchFiles = [
36 config.secrets.fullPaths."webapps/${app.environment}-piedsjaloux"
37 ];
38 };
39
40 secrets.keys = [
41 {
42 dest = "webapps/${app.environment}-piedsjaloux";
43 user = config.services.httpd.Inte.user;
44 group = config.services.httpd.Inte.group;
45 permissions = "0400";
46 text = ''
47 # This file is auto-generated during the composer install
48 parameters:
49 database_host: ${secrets.mysql.host}
50 database_port: ${secrets.mysql.port}
51 database_name: ${secrets.mysql.name}
52 database_user: ${secrets.mysql.user}
53 database_password: ${secrets.mysql.password}
54 database_server_version: ${pkgs.mariadb.mysqlVersion}
55 mailer_transport: smtp
56 mailer_host: 127.0.0.1
57 mailer_user: null
58 mailer_password: null
59 secret: ${secrets.secret}
60 pdflatex: "${pkgs.texlive.combine { inherit (pkgs.texlive) attachfile preprint scheme-small; }}/bin/pdflatex"
61 leapt_im:
62 binary_path: ${pkgs.imagemagick}/bin
63 '';
64 }
65 ];
66
67 services.websites.env.integration.vhostConfs.piedsjaloux_dev = {
68 certName = "eldiron";
f8026b6e
IB
69 addToCerts = true;
70 hosts = [ "piedsjaloux.immae.eu" ];
9f66adf4
IB
71 root = pcfg.webappDirs.piedsjaloux_dev;
72 extraConfig = [
73 ''
74 <FilesMatch "\.php$">
75 SetHandler "proxy:unix:${pcfg.phpListenPaths.piedsjaloux_dev}|fcgi://localhost"
76 </FilesMatch>
77
78 <Location />
79 Use LDAPConnect
80 Require ldap-group cn=piedsjaloux.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
81 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://piedsjaloux.fr\"></html>"
82 </Location>
83
84 <Directory ${pcfg.webappDirs.piedsjaloux_dev}>
85 Options Indexes FollowSymLinks MultiViews Includes
86 AllowOverride None
87 Require all granted
88
89 DirectoryIndex app_dev.php
90
91 <IfModule mod_negotiation.c>
92 Options -MultiViews
93 </IfModule>
94
95 <IfModule mod_rewrite.c>
96 RewriteEngine On
97
98 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
99 RewriteRule ^(.*) - [E=BASE:%1]
100
101 # Maintenance script
102 RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
103 RewriteCond %{SCRIPT_FILENAME} !maintenance.php
104 RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L]
105 ErrorDocument 503 /maintenance.php
106
107 # Sets the HTTP_AUTHORIZATION header removed by Apache
108 RewriteCond %{HTTP:Authorization} .
109 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
110
111 RewriteCond %{ENV:REDIRECT_STATUS} ^$
112 RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
113
114 # If the requested filename exists, simply serve it.
115 # We only want to let Apache serve files and not directories.
116 RewriteCond %{REQUEST_FILENAME} -f
117 RewriteRule ^ - [L]
118
119 # Rewrite all other queries to the front controller.
120 RewriteRule ^ %{ENV:BASE}/app_dev.php [L]
121 </IfModule>
122
123 </Directory>
124 ''
125 ];
f8026b6e
IB
126 };
127 };
128}