]>
Commit | Line | Data |
---|---|---|
1 | { lib, pkgs, config, ... }: | |
2 | let | |
3 | secrets = config.myEnv.websites.piedsjaloux.integration; | |
4 | app = pkgs.callPackage ./app { | |
5 | composerEnv = pkgs.composerEnv.override { php = pkgs.php72; }; | |
6 | environment = secrets.environment; | |
7 | varDir = "/var/lib/piedsjaloux_integration"; | |
8 | secretsPath = config.secrets.fullPaths."websites/piedsjaloux/integration"; | |
9 | }; | |
10 | cfg = config.myServices.websites.piedsjaloux.integration; | |
11 | pcfg = config.services.phpApplication; | |
12 | texlive = pkgs.texlive.combine { inherit (pkgs.texlive) attachfile preprint scheme-small; }; | |
13 | in { | |
14 | options.myServices.websites.piedsjaloux.integration.enable = lib.mkEnableOption "enable PiedsJaloux's website in integration"; | |
15 | ||
16 | config = lib.mkIf cfg.enable { | |
17 | services.duplyBackup.profiles.piedsjaloux_integration.rootDir = app.varDir; | |
18 | services.phpApplication.apps.piedsjaloux_integration = { | |
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" ]; | |
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 | 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\""; | |
48 | }; | |
49 | phpWatchFiles = [ | |
50 | app.secretsPath | |
51 | ]; | |
52 | phpPackage = pkgs.php72; | |
53 | }; | |
54 | ||
55 | secrets.keys = [ | |
56 | { | |
57 | dest = "websites/piedsjaloux/integration"; | |
58 | user = config.services.httpd.Inte.user; | |
59 | group = config.services.httpd.Inte.group; | |
60 | permissions = "0400"; | |
61 | text = '' | |
62 | # This file is auto-generated during the composer install | |
63 | parameters: | |
64 | database_host: ${secrets.mysql.host} | |
65 | database_port: ${secrets.mysql.port} | |
66 | database_name: ${secrets.mysql.database} | |
67 | database_user: ${secrets.mysql.user} | |
68 | database_password: ${secrets.mysql.password} | |
69 | database_server_version: ${pkgs.mariadb.mysqlVersion} | |
70 | mailer_transport: smtp | |
71 | mailer_host: 127.0.0.1 | |
72 | mailer_user: null | |
73 | mailer_password: null | |
74 | secret: ${secrets.secret} | |
75 | pdflatex: "${texlive}/bin/pdflatex" | |
76 | leapt_im: | |
77 | binary_path: ${pkgs.imagemagick}/bin | |
78 | ''; | |
79 | } | |
80 | ]; | |
81 | ||
82 | services.websites.env.integration.vhostConfs.piedsjaloux_integration = { | |
83 | certName = "integration"; | |
84 | addToCerts = true; | |
85 | hosts = [ "piedsjaloux.immae.eu" ]; | |
86 | root = pcfg.webappDirs.piedsjaloux_integration; | |
87 | extraConfig = [ | |
88 | '' | |
89 | <FilesMatch "\.php$"> | |
90 | SetHandler "proxy:unix:${pcfg.phpListenPaths.piedsjaloux_integration}|fcgi://localhost" | |
91 | </FilesMatch> | |
92 | ||
93 | <Location /> | |
94 | Use LDAPConnect | |
95 | Require ldap-group cn=piedsjaloux.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu | |
96 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://piedsjaloux.fr\"></html>" | |
97 | </Location> | |
98 | ||
99 | <Directory ${pcfg.webappDirs.piedsjaloux_integration}> | |
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 | ]; | |
141 | }; | |
142 | }; | |
143 | } |