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