]>
Commit | Line | Data |
---|---|---|
1 | { lib, pkgs, config, ... }: | |
2 | let | |
3 | secrets = config.myEnv.websites.piedsjaloux.integration; | |
4 | webRoot = "/var/lib/ftp/immae/piedsjaloux/web"; | |
5 | cfg = config.myServices.websites.piedsjaloux.integration; | |
6 | pcfg = config.services.phpApplication; | |
7 | texlive = pkgs.texlive.combine { inherit (pkgs.texlive) attachfile preprint scheme-small; }; | |
8 | in { | |
9 | options.myServices.websites.piedsjaloux.integration.enable = lib.mkEnableOption "enable PiedsJaloux's website in integration"; | |
10 | ||
11 | config = lib.mkIf cfg.enable { | |
12 | services.phpApplication.apps.piedsjaloux_integration = { | |
13 | websiteEnv = "integration"; | |
14 | httpdUser = config.services.httpd.Inte.user; | |
15 | httpdGroup = config.services.httpd.Inte.group; | |
16 | inherit webRoot; | |
17 | varDir = "/var/lib/ftp/immae/piedsjaloux_var"; | |
18 | varDirPaths = { | |
19 | "tmp" = "0700"; | |
20 | }; | |
21 | app = "/var/lib/ftp/immae/piedsjaloux"; | |
22 | serviceDeps = [ "mysql.service" ]; | |
23 | preStartActions = [ | |
24 | "./bin/console --env=dev cache:clear --no-warmup" | |
25 | ]; | |
26 | phpOpenbasedir = [ "/tmp" ]; | |
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 = { | |
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\""; | |
43 | }; | |
44 | phpWatchFiles = [ | |
45 | config.secrets.fullPaths."websites/piedsjaloux/integration" | |
46 | ]; | |
47 | phpPackage = pkgs.php72; | |
48 | }; | |
49 | ||
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 | }; | |
73 | ||
74 | services.websites.env.integration.vhostConfs.piedsjaloux_integration = { | |
75 | certName = "integration"; | |
76 | addToCerts = true; | |
77 | hosts = [ "test.pj.immae.dev" ]; | |
78 | root = webRoot; | |
79 | extraConfig = [ | |
80 | '' | |
81 | <FilesMatch "\.php$"> | |
82 | SetHandler "proxy:unix:${pcfg.phpListenPaths.piedsjaloux_integration}|fcgi://localhost" | |
83 | </FilesMatch> | |
84 | ||
85 | <Location /> | |
86 | Use LDAPConnect | |
87 | Require ldap-group cn=pj.immae.dev,cn=httpd,ou=services,dc=immae,dc=eu | |
88 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://piedsjaloux.fr\"></html>" | |
89 | </Location> | |
90 | ||
91 | <Directory ${webRoot}> | |
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 | ]; | |
133 | }; | |
134 | }; | |
135 | } |