]>
Commit | Line | Data |
---|---|---|
52e8779d IB |
1 | { connexionswing, pkgs, phpPackages, config }: |
2 | rec { | |
3 | app = connexionswing.override { inherit (config) environment; }; | |
4 | keys = [{ | |
5 | dest = "webapps/${app.environment}-connexionswing"; | |
6 | user = apache.user; | |
7 | group = apache.group; | |
8 | permissions = "0400"; | |
9 | text = '' | |
10 | # This file is auto-generated during the composer install | |
11 | parameters: | |
12 | database_host: ${config.mysql.host} | |
13 | database_port: ${config.mysql.port} | |
14 | database_name: ${config.mysql.name} | |
15 | database_user: ${config.mysql.user} | |
16 | database_password: ${config.mysql.password} | |
17 | database_server_version: ${pkgs.mariadb.mysqlVersion} | |
18 | mailer_transport: sendmail | |
19 | mailer_host: null | |
20 | mailer_user: null | |
21 | mailer_password: null | |
22 | subscription_email: ${config.email} | |
23 | allow_robots: true | |
24 | secret: ${config.secret} | |
25 | ${if app.environment == "prod" then '' | |
26 | services: | |
27 | swiftmailer.mailer.default.transport: | |
28 | class: Swift_SendmailTransport | |
29 | arguments: ['/run/wrappers/bin/sendmail -bs'] | |
30 | '' else ""} | |
31 | ''; | |
32 | }]; | |
33 | phpFpm = rec { | |
34 | preStart = '' | |
35 | if [ ! -f "${app.varDir}/currentWebappDir" -o \ | |
36 | ! -f "${app.varDir}/currentKey" -o \ | |
37 | "${app}" != "$(cat ${app.varDir}/currentWebappDir 2>/dev/null)" ] \ | |
38 | || ! sha512sum -c --status ${app.varDir}/currentKey; then | |
39 | pushd ${app} > /dev/null | |
40 | /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=${app.environment} cache:clear --no-warmup | |
41 | popd > /dev/null | |
42 | echo -n "${app}" > ${app.varDir}/currentWebappDir | |
43 | sha512sum /var/secrets/webapps/${app.environment}-connexionswing > ${app.varDir}/currentKey | |
44 | fi | |
940f1834 | 45 | ''; |
52e8779d IB |
46 | serviceDeps = [ "mysql.service" ]; |
47 | socket = "/var/run/phpfpm/connexionswing-${app.environment}.sock"; | |
48 | phpConfig = '' | |
49 | extension=${phpPackages.imagick}/lib/php/extensions/imagick.so | |
50 | ''; | |
51 | pool = '' | |
52 | listen = ${socket} | |
53 | user = ${apache.user} | |
54 | group = ${apache.group} | |
55 | listen.owner = ${apache.user} | |
56 | listen.group = ${apache.group} | |
57 | php_admin_value[upload_max_filesize] = 20M | |
58 | php_admin_value[post_max_size] = 20M | |
59 | ;php_admin_flag[log_errors] = on | |
60 | php_admin_value[open_basedir] = "/run/wrappers/bin/sendmail:/var/secrets/webapps/${app.environment}-connexionswing:${app}:${app.varDir}:/tmp" | |
61 | php_admin_value[session.save_path] = "${app.varDir}/phpSessions" | |
62 | ${if app.environment == "dev" then '' | |
63 | pm = ondemand | |
64 | pm.max_children = 5 | |
65 | pm.process_idle_timeout = 60 | |
66 | env[SYMFONY_DEBUG_MODE] = "yes" | |
67 | '' else '' | |
68 | pm = dynamic | |
69 | pm.max_children = 20 | |
70 | pm.start_servers = 2 | |
71 | pm.min_spare_servers = 1 | |
72 | pm.max_spare_servers = 3 | |
73 | ''}''; | |
74 | }; | |
75 | apache = rec { | |
76 | user = "wwwrun"; | |
77 | group = "wwwrun"; | |
78 | modules = [ "proxy_fcgi" ]; | |
79 | webappName = "connexionswing_${app.environment}"; | |
80 | root = "/run/current-system/webapps/${webappName}"; | |
81 | vhostConf = '' | |
82 | <FilesMatch "\.php$"> | |
83 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | |
84 | </FilesMatch> | |
940f1834 | 85 | |
52e8779d IB |
86 | <Directory ${app.varDir}/medias> |
87 | Options FollowSymLinks | |
88 | AllowOverride None | |
89 | Require all granted | |
90 | </Directory> | |
940f1834 | 91 | |
52e8779d IB |
92 | <Directory ${app.varDir}/uploads> |
93 | Options FollowSymLinks | |
94 | AllowOverride None | |
95 | Require all granted | |
96 | </Directory> | |
940f1834 | 97 | |
52e8779d IB |
98 | ${if app.environment == "dev" then '' |
99 | <Location /> | |
100 | Use LDAPConnect | |
101 | Require ldap-group cn=connexionswing.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu | |
102 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://connexionswing.com\"></html>" | |
103 | </Location> | |
940f1834 | 104 | |
52e8779d IB |
105 | <Directory ${root}> |
106 | Options Indexes FollowSymLinks MultiViews Includes | |
107 | AllowOverride None | |
108 | Require all granted | |
940f1834 | 109 | |
52e8779d | 110 | DirectoryIndex app_dev.php |
940f1834 | 111 | |
52e8779d IB |
112 | <IfModule mod_negotiation.c> |
113 | Options -MultiViews | |
114 | </IfModule> | |
940f1834 | 115 | |
52e8779d IB |
116 | <IfModule mod_rewrite.c> |
117 | RewriteEngine On | |
940f1834 | 118 | |
52e8779d IB |
119 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ |
120 | RewriteRule ^(.*) - [E=BASE:%1] | |
940f1834 | 121 | |
52e8779d IB |
122 | # Maintenance script |
123 | RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f | |
124 | RewriteCond %{SCRIPT_FILENAME} !maintenance.php | |
125 | RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L] | |
126 | ErrorDocument 503 /maintenance.php | |
940f1834 | 127 | |
52e8779d IB |
128 | # Sets the HTTP_AUTHORIZATION header removed by Apache |
129 | RewriteCond %{HTTP:Authorization} . | |
130 | RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | |
940f1834 | 131 | |
52e8779d IB |
132 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ |
133 | RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] | |
940f1834 | 134 | |
52e8779d IB |
135 | # If the requested filename exists, simply serve it. |
136 | # We only want to let Apache serve files and not directories. | |
137 | RewriteCond %{REQUEST_FILENAME} -f | |
138 | RewriteRule ^ - [L] | |
940f1834 | 139 | |
52e8779d IB |
140 | # Rewrite all other queries to the front controller. |
141 | RewriteRule ^ %{ENV:BASE}/app_dev.php [L] | |
142 | </IfModule> | |
940f1834 | 143 | |
52e8779d IB |
144 | </Directory> |
145 | '' else '' | |
146 | Use Stats connexionswing.com | |
527e32ad | 147 | |
52e8779d IB |
148 | <Directory ${root}> |
149 | Options Indexes FollowSymLinks MultiViews Includes | |
150 | AllowOverride All | |
151 | Require all granted | |
152 | </Directory> | |
153 | ''} | |
154 | ''; | |
155 | }; | |
156 | activationScript = { | |
157 | deps = [ "wrappers" ]; | |
158 | text = '' | |
159 | install -m 0755 -o ${apache.user} -g ${apache.group} -d ${app.varDir} \ | |
160 | ${app.varDir}/medias \ | |
161 | ${app.varDir}/uploads \ | |
162 | ${app.varDir}/var | |
163 | install -m 0750 -o ${apache.user} -g ${apache.group} -d ${app.varDir}/phpSessions | |
164 | ''; | |
940f1834 | 165 | }; |
52e8779d | 166 | } |