aboutsummaryrefslogtreecommitdiff
path: root/modules/private/websites/ludivinecassal
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2020-04-18 16:10:56 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2020-04-20 01:51:48 +0200
commitd3452fc59b9839846225fd254926c64a9c71f071 (patch)
treea98a0958b826ac4b2ab137720edf0195c65dd958 /modules/private/websites/ludivinecassal
parent514f9ec3beec470c4445be690673a0ceab9115b4 (diff)
downloadNix-d3452fc59b9839846225fd254926c64a9c71f071.tar.gz
Nix-d3452fc59b9839846225fd254926c64a9c71f071.tar.zst
Nix-d3452fc59b9839846225fd254926c64a9c71f071.zip
Refactor websites
Diffstat (limited to 'modules/private/websites/ludivinecassal')
-rw-r--r--modules/private/websites/ludivinecassal/integration.nix142
-rw-r--r--modules/private/websites/ludivinecassal/production.nix107
2 files changed, 0 insertions, 249 deletions
diff --git a/modules/private/websites/ludivinecassal/integration.nix b/modules/private/websites/ludivinecassal/integration.nix
deleted file mode 100644
index d304fdf..0000000
--- a/modules/private/websites/ludivinecassal/integration.nix
+++ /dev/null
@@ -1,142 +0,0 @@
1{ lib, pkgs, config, ... }:
2let
3 secrets = config.myEnv.websites.ludivinecassal.integration;
4 app = pkgs.webapps.ludivinecassal.override { environment = secrets.environment; };
5 cfg = config.myServices.websites.ludivinecassal.integration;
6 pcfg = config.services.phpApplication;
7in {
8 options.myServices.websites.ludivinecassal.integration.enable = lib.mkEnableOption "enable Ludivine's website in integration";
9
10 config = lib.mkIf cfg.enable {
11 services.duplyBackup.profiles.ludivinecassal_dev.rootDir = app.varDir;
12 services.phpApplication.apps.ludivinecassal_dev = {
13 websiteEnv = "integration";
14 httpdUser = config.services.httpd.Inte.user;
15 httpdGroup = config.services.httpd.Inte.group;
16 inherit (app) webRoot varDir;
17 varDirPaths = {
18 "tmp" = "0700";
19 };
20 inherit app;
21 serviceDeps = [ "mysql.service" ];
22 preStartActions = [
23 "./bin/console --env=${app.environment} cache:clear --no-warmup"
24 ];
25 phpOpenbasedir = [ "/tmp" ];
26 phpPool = {
27 "php_admin_value[upload_max_filesize]" = "20M";
28 "php_admin_value[post_max_size]" = "20M";
29 #"php_admin_flag[log_errors]" = "on";
30 "pm" = "ondemand";
31 "pm.max_children" = "5";
32 "pm.process_idle_timeout" = "60";
33 };
34 phpEnv = {
35 SYMFONY_DEBUG_MODE = "yes";
36 };
37 phpWatchFiles = [
38 config.secrets.fullPaths."webapps/${app.environment}-ludivinecassal"
39 ];
40 };
41
42 secrets.keys = [
43 {
44 dest = "webapps/${app.environment}-ludivinecassal";
45 user = config.services.httpd.Inte.user;
46 group = config.services.httpd.Inte.group;
47 permissions = "0400";
48 text = ''
49 # This file is auto-generated during the composer install
50 parameters:
51 database_host: ${secrets.mysql.host}
52 database_port: ${secrets.mysql.port}
53 database_name: ${secrets.mysql.database}
54 database_user: ${secrets.mysql.user}
55 database_password: ${secrets.mysql.password}
56 database_server_version: ${pkgs.mariadb.mysqlVersion}
57 mailer_transport: smtp
58 mailer_host: 127.0.0.1
59 mailer_user: null
60 mailer_password: null
61 secret: ${secrets.secret}
62 ldap_host: ldap.immae.eu
63 ldap_port: 636
64 ldap_version: 3
65 ldap_ssl: true
66 ldap_tls: false
67 ldap_user_bind: 'uid={username},ou=users,dc=immae,dc=eu'
68 ldap_base_dn: 'dc=immae,dc=eu'
69 ldap_search_dn: '${secrets.ldap.dn}'
70 ldap_search_password: '${secrets.ldap.password}'
71 ldap_search_filter: '${secrets.ldap.filter}'
72 leapt_im:
73 binary_path: ${pkgs.imagemagick}/bin
74 assetic:
75 sass: ${pkgs.sass}/bin/sass
76 ruby: ${pkgs.ruby}/bin/ruby
77 '';
78 }
79 ];
80
81 services.websites.env.integration.vhostConfs.ludivinecassal_dev = {
82 certName = "integration";
83 addToCerts = true;
84 hosts = [ "ludivine.immae.eu" ];
85 root = pcfg.webappDirs.ludivinecassal_dev;
86 extraConfig = [
87 ''
88 <FilesMatch "\.php$">
89 SetHandler "proxy:unix:${pcfg.phpListenPaths.ludivinecassal_dev}|fcgi://localhost"
90 </FilesMatch>
91
92 <Location />
93 Use LDAPConnect
94 Require ldap-group cn=ludivine.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu
95 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://ludivinecassal.com\"></html>"
96 </Location>
97
98 <Directory ${pcfg.webappDirs.ludivinecassal_dev}>
99 Options Indexes FollowSymLinks MultiViews Includes
100 AllowOverride None
101 Require all granted
102
103 DirectoryIndex app_dev.php
104
105 <IfModule mod_negotiation.c>
106 Options -MultiViews
107 </IfModule>
108
109 <IfModule mod_rewrite.c>
110 RewriteEngine On
111
112 RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
113 RewriteRule ^(.*) - [E=BASE:%1]
114
115 # Maintenance script
116 RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f
117 RewriteCond %{SCRIPT_FILENAME} !maintenance.php
118 RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L]
119 ErrorDocument 503 /maintenance.php
120
121 # Sets the HTTP_AUTHORIZATION header removed by Apache
122 RewriteCond %{HTTP:Authorization} .
123 RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
124
125 RewriteCond %{ENV:REDIRECT_STATUS} ^$
126 RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L]
127
128 # If the requested filename exists, simply serve it.
129 # We only want to let Apache serve files and not directories.
130 RewriteCond %{REQUEST_FILENAME} -f
131 RewriteRule ^ - [L]
132
133 # Rewrite all other queries to the front controller.
134 RewriteRule ^ %{ENV:BASE}/app_dev.php [L]
135 </IfModule>
136
137 </Directory>
138 ''
139 ];
140 };
141 };
142}
diff --git a/modules/private/websites/ludivinecassal/production.nix b/modules/private/websites/ludivinecassal/production.nix
deleted file mode 100644
index 5761be7..0000000
--- a/modules/private/websites/ludivinecassal/production.nix
+++ /dev/null
@@ -1,107 +0,0 @@
1{ lib, pkgs, config, ... }:
2let
3 secrets = config.myEnv.websites.ludivinecassal.production;
4 app = pkgs.webapps.ludivinecassal.override { environment = secrets.environment; };
5 pcfg = config.services.phpApplication;
6 cfg = config.myServices.websites.ludivinecassal.production;
7in {
8 options.myServices.websites.ludivinecassal.production.enable = lib.mkEnableOption "enable Ludivine's website in production";
9
10 config = lib.mkIf cfg.enable {
11 services.duplyBackup.profiles.ludivinecassal_prod.rootDir = app.varDir;
12 services.webstats.sites = [ { name = "ludivinecassal.com"; } ];
13 services.phpApplication.apps.ludivinecassal_prod = {
14 websiteEnv = "production";
15 httpdUser = config.services.httpd.Prod.user;
16 httpdGroup = config.services.httpd.Prod.group;
17 inherit (app) webRoot varDir;
18 varDirPaths = {
19 "tmp" = "0700";
20 };
21 inherit app;
22 serviceDeps = [ "mysql.service" ];
23 preStartActions = [
24 "./bin/console --env=${app.environment} 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" = "dynamic";
32 "pm.max_children" = "20";
33 "pm.start_servers" = "2";
34 "pm.min_spare_servers" = "1";
35 "pm.max_spare_servers" = "3";
36 };
37 phpWatchFiles = [
38 config.secrets.fullPaths."webapps/${app.environment}-ludivinecassal"
39 ];
40 };
41
42 secrets.keys = [
43 {
44 dest = "webapps/${app.environment}-ludivinecassal";
45 user = config.services.httpd.Prod.user;
46 group = config.services.httpd.Prod.group;
47 permissions = "0400";
48 text = ''
49 # This file is auto-generated during the composer install
50 parameters:
51 database_host: ${secrets.mysql.host}
52 database_port: ${secrets.mysql.port}
53 database_name: ${secrets.mysql.database}
54 database_user: ${secrets.mysql.user}
55 database_password: ${secrets.mysql.password}
56 database_server_version: ${pkgs.mariadb.mysqlVersion}
57 mailer_transport: smtp
58 mailer_host: 127.0.0.1
59 mailer_user: null
60 mailer_password: null
61 secret: ${secrets.secret}
62 ldap_host: ldap.immae.eu
63 ldap_port: 636
64 ldap_version: 3
65 ldap_ssl: true
66 ldap_tls: false
67 ldap_user_bind: 'uid={username},ou=users,dc=immae,dc=eu'
68 ldap_base_dn: 'dc=immae,dc=eu'
69 ldap_search_dn: '${secrets.ldap.dn}'
70 ldap_search_password: '${secrets.ldap.password}'
71 ldap_search_filter: '${secrets.ldap.filter}'
72 leapt_im:
73 binary_path: ${pkgs.imagemagick}/bin
74 assetic:
75 sass: ${pkgs.sass}/bin/sass
76 ruby: ${pkgs.ruby}/bin/ruby
77 '';
78 }
79 ];
80
81 services.websites.env.production.vhostConfs.ludivinecassal_prod = {
82 certName = "ludivinecassal";
83 certMainHost = "ludivinecassal.com";
84 hosts = ["ludivinecassal.com" "www.ludivinecassal.com" ];
85 root = pcfg.webappDirs.ludivinecassal_prod;
86 extraConfig = [
87 ''
88 RewriteEngine on
89 RewriteCond "%{HTTP_HOST}" "!^ludivinecassal\.com$" [NC]
90 RewriteRule ^(.+)$ https://ludivinecassal.com$1 [R=302,L]
91
92 <FilesMatch "\.php$">
93 SetHandler "proxy:unix:${pcfg.phpListenPaths.ludivinecassal_prod}|fcgi://localhost"
94 </FilesMatch>
95
96 Use Stats ludivinecassal.com
97
98 <Directory ${pcfg.webappDirs.ludivinecassal_prod}>
99 Options Indexes FollowSymLinks MultiViews Includes
100 AllowOverride All
101 Require all granted
102 </Directory>
103 ''
104 ];
105 };
106 };
107}