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