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