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