]>
Commit | Line | Data |
---|---|---|
ab8f306d | 1 | { lib, pkgs, config, ... }: |
f8026b6e | 2 | let |
ab8f306d | 3 | secrets = config.myEnv.websites.piedsjaloux.integration; |
41cce84a | 4 | webRoot = "/var/lib/ftp/immae/piedsjaloux/web"; |
f8026b6e | 5 | cfg = config.myServices.websites.piedsjaloux.integration; |
9f66adf4 | 6 | pcfg = config.services.phpApplication; |
d3452fc5 | 7 | texlive = pkgs.texlive.combine { inherit (pkgs.texlive) attachfile preprint scheme-small; }; |
f8026b6e IB |
8 | in { |
9 | options.myServices.websites.piedsjaloux.integration.enable = lib.mkEnableOption "enable PiedsJaloux's website in integration"; | |
10 | ||
11 | config = lib.mkIf cfg.enable { | |
d3452fc5 | 12 | services.phpApplication.apps.piedsjaloux_integration = { |
9f66adf4 IB |
13 | websiteEnv = "integration"; |
14 | httpdUser = config.services.httpd.Inte.user; | |
15 | httpdGroup = config.services.httpd.Inte.group; | |
41cce84a IB |
16 | inherit webRoot; |
17 | varDir = "/var/lib/ftp/immae/piedsjaloux_var"; | |
9f66adf4 IB |
18 | varDirPaths = { |
19 | "tmp" = "0700"; | |
20 | }; | |
41cce84a | 21 | app = "/var/lib/ftp/immae/piedsjaloux"; |
9f66adf4 IB |
22 | serviceDeps = [ "mysql.service" ]; |
23 | preStartActions = [ | |
41cce84a | 24 | "./bin/console --env=dev cache:clear --no-warmup" |
9f66adf4 IB |
25 | ]; |
26 | phpOpenbasedir = [ "/tmp" ]; | |
5400b9b6 IB |
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 | }; | |
35 | phpEnv = { | |
d3452fc5 IB |
36 | PATH = lib.makeBinPath [ |
37 | pkgs.apg pkgs.unzip | |
38 | # below ones don't need to be in the PATH but they’re used in | |
39 | # secrets | |
40 | pkgs.imagemagick texlive | |
41 | ]; | |
42 | SYMFONY_DEBUG_MODE = "\"yes\""; | |
5400b9b6 | 43 | }; |
9f66adf4 | 44 | phpWatchFiles = [ |
41cce84a | 45 | config.secrets.fullPaths."websites/piedsjaloux/integration" |
9f66adf4 | 46 | ]; |
dcac3ec7 | 47 | phpPackage = pkgs.php72; |
9f66adf4 IB |
48 | }; |
49 | ||
4c4652aa IB |
50 | secrets.keys."websites/piedsjaloux/integration" = { |
51 | user = config.services.httpd.Inte.user; | |
52 | group = config.services.httpd.Inte.group; | |
53 | permissions = "0400"; | |
54 | text = '' | |
55 | # This file is auto-generated during the composer install | |
56 | parameters: | |
57 | database_host: ${secrets.mysql.host} | |
58 | database_port: ${secrets.mysql.port} | |
59 | database_name: ${secrets.mysql.database} | |
60 | database_user: ${secrets.mysql.user} | |
61 | database_password: ${secrets.mysql.password} | |
62 | database_server_version: ${pkgs.mariadb.mysqlVersion} | |
63 | mailer_transport: smtp | |
64 | mailer_host: 127.0.0.1 | |
65 | mailer_user: null | |
66 | mailer_password: null | |
67 | secret: ${secrets.secret} | |
68 | pdflatex: "${texlive}/bin/pdflatex" | |
69 | leapt_im: | |
70 | binary_path: ${pkgs.imagemagick}/bin | |
71 | ''; | |
72 | }; | |
9f66adf4 | 73 | |
d3452fc5 | 74 | services.websites.env.integration.vhostConfs.piedsjaloux_integration = { |
0f71cd76 | 75 | certName = "integration"; |
f8026b6e | 76 | addToCerts = true; |
7c5e6fe8 | 77 | hosts = [ "test.pj.immae.dev" ]; |
41cce84a | 78 | root = webRoot; |
9f66adf4 IB |
79 | extraConfig = [ |
80 | '' | |
81 | <FilesMatch "\.php$"> | |
d3452fc5 | 82 | SetHandler "proxy:unix:${pcfg.phpListenPaths.piedsjaloux_integration}|fcgi://localhost" |
9f66adf4 IB |
83 | </FilesMatch> |
84 | ||
85 | <Location /> | |
86 | Use LDAPConnect | |
7c5e6fe8 | 87 | Require ldap-group cn=pj.immae.dev,cn=httpd,ou=services,dc=immae,dc=eu |
9f66adf4 IB |
88 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://piedsjaloux.fr\"></html>" |
89 | </Location> | |
90 | ||
41cce84a | 91 | <Directory ${webRoot}> |
9f66adf4 IB |
92 | Options Indexes FollowSymLinks MultiViews Includes |
93 | AllowOverride None | |
94 | Require all granted | |
95 | ||
96 | DirectoryIndex app_dev.php | |
97 | ||
98 | <IfModule mod_negotiation.c> | |
99 | Options -MultiViews | |
100 | </IfModule> | |
101 | ||
102 | <IfModule mod_rewrite.c> | |
103 | RewriteEngine On | |
104 | ||
105 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ | |
106 | RewriteRule ^(.*) - [E=BASE:%1] | |
107 | ||
108 | # Maintenance script | |
109 | RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f | |
110 | RewriteCond %{SCRIPT_FILENAME} !maintenance.php | |
111 | RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L] | |
112 | ErrorDocument 503 /maintenance.php | |
113 | ||
114 | # Sets the HTTP_AUTHORIZATION header removed by Apache | |
115 | RewriteCond %{HTTP:Authorization} . | |
116 | RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | |
117 | ||
118 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ | |
119 | RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] | |
120 | ||
121 | # If the requested filename exists, simply serve it. | |
122 | # We only want to let Apache serve files and not directories. | |
123 | RewriteCond %{REQUEST_FILENAME} -f | |
124 | RewriteRule ^ - [L] | |
125 | ||
126 | # Rewrite all other queries to the front controller. | |
127 | RewriteRule ^ %{ENV:BASE}/app_dev.php [L] | |
128 | </IfModule> | |
129 | ||
130 | </Directory> | |
131 | '' | |
132 | ]; | |
f8026b6e IB |
133 | }; |
134 | }; | |
135 | } |