]>
Commit | Line | Data |
---|---|---|
f8026b6e | 1 | { apacheUser, apacheGroup, connexionswing, pkgs, phpPackages, config }: |
52e8779d IB |
2 | rec { |
3 | app = connexionswing.override { inherit (config) environment; }; | |
4 | keys = [{ | |
5 | dest = "webapps/${app.environment}-connexionswing"; | |
f8026b6e IB |
6 | user = apacheUser; |
7 | group = apacheGroup; | |
52e8779d IB |
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 | |
f8026b6e | 40 | /run/wrappers/bin/sudo -u ${apacheUser} ./bin/console --env=${app.environment} cache:clear --no-warmup |
52e8779d IB |
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} | |
f8026b6e IB |
53 | user = ${apacheUser} |
54 | group = ${apacheGroup} | |
55 | listen.owner = ${apacheUser} | |
56 | listen.group = ${apacheGroup} | |
52e8779d IB |
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 { | |
52e8779d IB |
76 | modules = [ "proxy_fcgi" ]; |
77 | webappName = "connexionswing_${app.environment}"; | |
78 | root = "/run/current-system/webapps/${webappName}"; | |
79 | vhostConf = '' | |
80 | <FilesMatch "\.php$"> | |
81 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | |
82 | </FilesMatch> | |
940f1834 | 83 | |
52e8779d IB |
84 | <Directory ${app.varDir}/medias> |
85 | Options FollowSymLinks | |
86 | AllowOverride None | |
87 | Require all granted | |
88 | </Directory> | |
940f1834 | 89 | |
52e8779d IB |
90 | <Directory ${app.varDir}/uploads> |
91 | Options FollowSymLinks | |
92 | AllowOverride None | |
93 | Require all granted | |
94 | </Directory> | |
940f1834 | 95 | |
52e8779d IB |
96 | ${if app.environment == "dev" then '' |
97 | <Location /> | |
98 | Use LDAPConnect | |
99 | Require ldap-group cn=connexionswing.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu | |
100 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://connexionswing.com\"></html>" | |
101 | </Location> | |
940f1834 | 102 | |
52e8779d IB |
103 | <Directory ${root}> |
104 | Options Indexes FollowSymLinks MultiViews Includes | |
105 | AllowOverride None | |
106 | Require all granted | |
940f1834 | 107 | |
52e8779d | 108 | DirectoryIndex app_dev.php |
940f1834 | 109 | |
52e8779d IB |
110 | <IfModule mod_negotiation.c> |
111 | Options -MultiViews | |
112 | </IfModule> | |
940f1834 | 113 | |
52e8779d IB |
114 | <IfModule mod_rewrite.c> |
115 | RewriteEngine On | |
940f1834 | 116 | |
52e8779d IB |
117 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ |
118 | RewriteRule ^(.*) - [E=BASE:%1] | |
940f1834 | 119 | |
52e8779d IB |
120 | # Maintenance script |
121 | RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f | |
122 | RewriteCond %{SCRIPT_FILENAME} !maintenance.php | |
123 | RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L] | |
124 | ErrorDocument 503 /maintenance.php | |
940f1834 | 125 | |
52e8779d IB |
126 | # Sets the HTTP_AUTHORIZATION header removed by Apache |
127 | RewriteCond %{HTTP:Authorization} . | |
128 | RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | |
940f1834 | 129 | |
52e8779d IB |
130 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ |
131 | RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] | |
940f1834 | 132 | |
52e8779d IB |
133 | # If the requested filename exists, simply serve it. |
134 | # We only want to let Apache serve files and not directories. | |
135 | RewriteCond %{REQUEST_FILENAME} -f | |
136 | RewriteRule ^ - [L] | |
940f1834 | 137 | |
52e8779d IB |
138 | # Rewrite all other queries to the front controller. |
139 | RewriteRule ^ %{ENV:BASE}/app_dev.php [L] | |
140 | </IfModule> | |
940f1834 | 141 | |
52e8779d IB |
142 | </Directory> |
143 | '' else '' | |
144 | Use Stats connexionswing.com | |
527e32ad | 145 | |
52e8779d IB |
146 | <Directory ${root}> |
147 | Options Indexes FollowSymLinks MultiViews Includes | |
148 | AllowOverride All | |
149 | Require all granted | |
150 | </Directory> | |
151 | ''} | |
152 | ''; | |
153 | }; | |
154 | activationScript = { | |
155 | deps = [ "wrappers" ]; | |
156 | text = '' | |
f8026b6e | 157 | install -m 0755 -o ${apacheUser} -g ${apacheGroup} -d ${app.varDir} \ |
52e8779d IB |
158 | ${app.varDir}/medias \ |
159 | ${app.varDir}/uploads \ | |
160 | ${app.varDir}/var | |
f8026b6e | 161 | install -m 0750 -o ${apacheUser} -g ${apacheGroup} -d ${app.varDir}/phpSessions |
52e8779d | 162 | ''; |
940f1834 | 163 | }; |
52e8779d | 164 | } |