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