]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - modules/private/websites/piedsjaloux/integration.nix
Remove webappdirs
[perso/Immae/Config/Nix.git] / modules / private / websites / piedsjaloux / integration.nix
CommitLineData
ab8f306d 1{ lib, pkgs, config, ... }:
f8026b6e 2let
ab8f306d 3 secrets = config.myEnv.websites.piedsjaloux.integration;
d3452fc5 4 app = pkgs.callPackage ./app {
dcac3ec7 5 composerEnv = pkgs.composerEnv.override { php = pkgs.php72; };
d3452fc5
IB
6 environment = secrets.environment;
7 varDir = "/var/lib/piedsjaloux_integration";
8 secretsPath = config.secrets.fullPaths."websites/piedsjaloux/integration";
9 };
f8026b6e 10 cfg = config.myServices.websites.piedsjaloux.integration;
9f66adf4 11 pcfg = config.services.phpApplication;
d3452fc5 12 texlive = pkgs.texlive.combine { inherit (pkgs.texlive) attachfile preprint scheme-small; };
f8026b6e
IB
13in {
14 options.myServices.websites.piedsjaloux.integration.enable = lib.mkEnableOption "enable PiedsJaloux's website in integration";
15
16 config = lib.mkIf cfg.enable {
d3452fc5
IB
17 services.duplyBackup.profiles.piedsjaloux_integration.rootDir = app.varDir;
18 services.phpApplication.apps.piedsjaloux_integration = {
9f66adf4
IB
19 websiteEnv = "integration";
20 httpdUser = config.services.httpd.Inte.user;
21 httpdGroup = config.services.httpd.Inte.group;
22 inherit (app) webRoot varDir;
23 varDirPaths = {
24 "tmp" = "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" ];
5400b9b6
IB
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 = {
d3452fc5
IB
41 PATH = lib.makeBinPath [
42 pkgs.apg pkgs.unzip
43 # below ones don't need to be in the PATH but they’re used in
44 # secrets
45 pkgs.imagemagick texlive
46 ];
47 SYMFONY_DEBUG_MODE = "\"yes\"";
5400b9b6 48 };
9f66adf4 49 phpWatchFiles = [
d3452fc5 50 app.secretsPath
9f66adf4 51 ];
dcac3ec7 52 phpPackage = pkgs.php72;
9f66adf4
IB
53 };
54
4c4652aa
IB
55 secrets.keys."websites/piedsjaloux/integration" = {
56 user = config.services.httpd.Inte.user;
57 group = config.services.httpd.Inte.group;
58 permissions = "0400";
59 text = ''
60 # This file is auto-generated during the composer install
61 parameters:
62 database_host: ${secrets.mysql.host}
63 database_port: ${secrets.mysql.port}
64 database_name: ${secrets.mysql.database}
65 database_user: ${secrets.mysql.user}
66 database_password: ${secrets.mysql.password}
67 database_server_version: ${pkgs.mariadb.mysqlVersion}
68 mailer_transport: smtp
69 mailer_host: 127.0.0.1
70 mailer_user: null
71 mailer_password: null
72 secret: ${secrets.secret}
73 pdflatex: "${texlive}/bin/pdflatex"
74 leapt_im:
75 binary_path: ${pkgs.imagemagick}/bin
76 '';
77 };
9f66adf4 78
d3452fc5 79 services.websites.env.integration.vhostConfs.piedsjaloux_integration = {
0f71cd76 80 certName = "integration";
f8026b6e
IB
81 addToCerts = true;
82 hosts = [ "piedsjaloux.immae.eu" ];
750fe5a4 83 root = app.webRoot;
9f66adf4
IB
84 extraConfig = [
85 ''
86 <FilesMatch "\.php$">
d3452fc5 87 SetHandler "proxy:unix:${pcfg.phpListenPaths.piedsjaloux_integration}|fcgi://localhost"
9f66adf4
IB
88 </FilesMatch>
89
90 <Location />
91 Use LDAPConnect
92 Require ldap-group cn=piedsjaloux.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
93 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://piedsjaloux.fr\"></html>"
94 </Location>
95
750fe5a4 96 <Directory ${app.webRoot}>
9f66adf4
IB
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 ];
f8026b6e
IB
138 };
139 };
140}