diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-18 10:49:00 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-18 10:49:00 +0200 |
commit | f8026b6e4c869aa108f6361c8ccd50890657994d (patch) | |
tree | 57cb311e520933bd2ab6ccbae05f2913799eb49e /nixops/modules/websites/connexionswing/connexionswing.nix | |
parent | 4aac110f17f0528d90510eec00c9a8df60bcf04f (diff) | |
download | Nix-f8026b6e4c869aa108f6361c8ccd50890657994d.tar.gz Nix-f8026b6e4c869aa108f6361c8ccd50890657994d.tar.zst Nix-f8026b6e4c869aa108f6361c8ccd50890657994d.zip |
Move personal websites to modules
Diffstat (limited to 'nixops/modules/websites/connexionswing/connexionswing.nix')
-rw-r--r-- | nixops/modules/websites/connexionswing/connexionswing.nix | 166 |
1 files changed, 0 insertions, 166 deletions
diff --git a/nixops/modules/websites/connexionswing/connexionswing.nix b/nixops/modules/websites/connexionswing/connexionswing.nix deleted file mode 100644 index 77b839c..0000000 --- a/nixops/modules/websites/connexionswing/connexionswing.nix +++ /dev/null | |||
@@ -1,166 +0,0 @@ | |||
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 | ||
45 | ''; | ||
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> | ||
85 | |||
86 | <Directory ${app.varDir}/medias> | ||
87 | Options FollowSymLinks | ||
88 | AllowOverride None | ||
89 | Require all granted | ||
90 | </Directory> | ||
91 | |||
92 | <Directory ${app.varDir}/uploads> | ||
93 | Options FollowSymLinks | ||
94 | AllowOverride None | ||
95 | Require all granted | ||
96 | </Directory> | ||
97 | |||
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> | ||
104 | |||
105 | <Directory ${root}> | ||
106 | Options Indexes FollowSymLinks MultiViews Includes | ||
107 | AllowOverride None | ||
108 | Require all granted | ||
109 | |||
110 | DirectoryIndex app_dev.php | ||
111 | |||
112 | <IfModule mod_negotiation.c> | ||
113 | Options -MultiViews | ||
114 | </IfModule> | ||
115 | |||
116 | <IfModule mod_rewrite.c> | ||
117 | RewriteEngine On | ||
118 | |||
119 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ | ||
120 | RewriteRule ^(.*) - [E=BASE:%1] | ||
121 | |||
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 | ||
127 | |||
128 | # Sets the HTTP_AUTHORIZATION header removed by Apache | ||
129 | RewriteCond %{HTTP:Authorization} . | ||
130 | RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | ||
131 | |||
132 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ | ||
133 | RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] | ||
134 | |||
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] | ||
139 | |||
140 | # Rewrite all other queries to the front controller. | ||
141 | RewriteRule ^ %{ENV:BASE}/app_dev.php [L] | ||
142 | </IfModule> | ||
143 | |||
144 | </Directory> | ||
145 | '' else '' | ||
146 | Use Stats connexionswing.com | ||
147 | |||
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 | ''; | ||
165 | }; | ||
166 | } | ||