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