diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-06-02 22:53:54 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-06-02 22:53:54 +0200 |
commit | 9f66adf4372a3b1c859dc053489f727aa360077e (patch) | |
tree | 1f1333f2fe59f5e77a6737c42dcd379f9c587a5c /modules/private | |
parent | 1594c8da6fbb4ffa09ab970fb887cea61c572f60 (diff) | |
download | Nix-9f66adf4372a3b1c859dc053489f727aa360077e.tar.gz Nix-9f66adf4372a3b1c859dc053489f727aa360077e.tar.zst Nix-9f66adf4372a3b1c859dc053489f727aa360077e.zip |
Move integration php applications to dedicated module
Diffstat (limited to 'modules/private')
-rw-r--r-- | modules/private/websites/aten/integration.nix | 2 | ||||
-rw-r--r-- | modules/private/websites/aten/production.nix | 2 | ||||
-rw-r--r-- | modules/private/websites/connexionswing/integration.nix | 154 | ||||
-rw-r--r-- | modules/private/websites/florian/app.nix | 4 | ||||
-rw-r--r-- | modules/private/websites/ludivinecassal/integration.nix | 151 | ||||
-rw-r--r-- | modules/private/websites/piedsjaloux/integration.nix | 136 |
6 files changed, 374 insertions, 75 deletions
diff --git a/modules/private/websites/aten/integration.nix b/modules/private/websites/aten/integration.nix index 38068a7..6768f80 100644 --- a/modules/private/websites/aten/integration.nix +++ b/modules/private/websites/aten/integration.nix | |||
@@ -36,7 +36,7 @@ in { | |||
36 | secrets.keys = [{ | 36 | secrets.keys = [{ |
37 | dest = "webapps/${app.environment}-aten"; | 37 | dest = "webapps/${app.environment}-aten"; |
38 | user = config.services.httpd.Inte.user; | 38 | user = config.services.httpd.Inte.user; |
39 | group = config.services.httpd.Inte.user; | 39 | group = config.services.httpd.Inte.group; |
40 | permissions = "0400"; | 40 | permissions = "0400"; |
41 | text = '' | 41 | text = '' |
42 | SetEnv APP_ENV "${app.environment}" | 42 | SetEnv APP_ENV "${app.environment}" |
diff --git a/modules/private/websites/aten/production.nix b/modules/private/websites/aten/production.nix index 21ecdcf..97f4a08 100644 --- a/modules/private/websites/aten/production.nix +++ b/modules/private/websites/aten/production.nix | |||
@@ -38,7 +38,7 @@ in { | |||
38 | secrets.keys = [{ | 38 | secrets.keys = [{ |
39 | dest = "webapps/${app.environment}-aten"; | 39 | dest = "webapps/${app.environment}-aten"; |
40 | user = config.services.httpd.Prod.user; | 40 | user = config.services.httpd.Prod.user; |
41 | group = config.services.httpd.Prod.user; | 41 | group = config.services.httpd.Prod.group; |
42 | permissions = "0400"; | 42 | permissions = "0400"; |
43 | text = '' | 43 | text = '' |
44 | SetEnv APP_ENV "${app.environment}" | 44 | SetEnv APP_ENV "${app.environment}" |
diff --git a/modules/private/websites/connexionswing/integration.nix b/modules/private/websites/connexionswing/integration.nix index 795d532..2ceaffa 100644 --- a/modules/private/websites/connexionswing/integration.nix +++ b/modules/private/websites/connexionswing/integration.nix | |||
@@ -1,40 +1,140 @@ | |||
1 | { lib, pkgs, config, myconfig, ... }: | 1 | { lib, pkgs, config, myconfig, ... }: |
2 | let | 2 | let |
3 | connexionswing = pkgs.callPackage ./builder.nix { | 3 | secrets = myconfig.env.websites.connexionswing.integration; |
4 | inherit (pkgs.webapps) connexionswing; | 4 | app = pkgs.webapps.connexionswing.override { environment = secrets.environment; }; |
5 | config = myconfig.env.websites.connexionswing.integration; | ||
6 | apacheUser = config.services.httpd.Inte.user; | ||
7 | apacheGroup = config.services.httpd.Inte.group; | ||
8 | }; | ||
9 | |||
10 | cfg = config.myServices.websites.connexionswing.integration; | 5 | cfg = config.myServices.websites.connexionswing.integration; |
6 | pcfg = config.services.phpApplication; | ||
11 | in { | 7 | in { |
12 | options.myServices.websites.connexionswing.integration.enable = lib.mkEnableOption "enable Connexionswing's website in integration"; | 8 | options.myServices.websites.connexionswing.integration.enable = lib.mkEnableOption "enable Connexionswing's website in integration"; |
13 | 9 | ||
14 | config = lib.mkIf cfg.enable { | 10 | config = lib.mkIf cfg.enable { |
15 | secrets.keys = connexionswing.keys; | 11 | services.phpApplication.apps.connexionswing_dev = { |
16 | systemd.services.phpfpm-connexionswing_dev.after = lib.mkAfter connexionswing.phpFpm.serviceDeps; | 12 | websiteEnv = "integration"; |
17 | systemd.services.phpfpm-connexionswing_dev.wants = connexionswing.phpFpm.serviceDeps; | 13 | httpdUser = config.services.httpd.Inte.user; |
18 | systemd.services.phpfpm-connexionswing_dev.preStart = lib.mkAfter connexionswing.phpFpm.preStart; | 14 | httpdGroup = config.services.httpd.Inte.group; |
19 | services.phpfpm.pools.connexionswing_dev = { | 15 | inherit (app) webRoot varDir; |
20 | listen = connexionswing.phpFpm.socket; | 16 | varDirPaths = { |
21 | extraConfig = connexionswing.phpFpm.pool; | 17 | "medias" = "0700"; |
22 | phpOptions = config.services.phpfpm.phpOptions + connexionswing.phpFpm.phpConfig; | 18 | "uploads" = "0700"; |
19 | "var" = "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" "/run/wrappers/bin/sendmail" ]; | ||
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 = ondemand | ||
32 | pm.max_children = 5 | ||
33 | pm.process_idle_timeout = 60 | ||
34 | env[SYMFONY_DEBUG_MODE] = "yes" | ||
35 | ''; | ||
36 | phpWatchFiles = [ | ||
37 | config.secrets.fullPaths."webapps/${app.environment}-connexionswing" | ||
38 | ]; | ||
23 | }; | 39 | }; |
24 | system.activationScripts.connexionswing_dev = connexionswing.activationScript; | 40 | |
25 | myServices.websites.webappDirs."${connexionswing.apache.webappName}" = connexionswing.app.webRoot; | 41 | secrets.keys = [ |
26 | services.websites.env.integration.modules = connexionswing.apache.modules; | 42 | { |
27 | services.websites.env.integration.vhostConfs.connexionswing = { | 43 | dest = "webapps/${app.environment}-connexionswing"; |
28 | certName = "eldiron"; | 44 | user = config.services.httpd.Inte.user; |
45 | group = config.services.httpd.Inte.group; | ||
46 | permissions = "0400"; | ||
47 | text = '' | ||
48 | # This file is auto-generated during the composer install | ||
49 | parameters: | ||
50 | database_host: ${secrets.mysql.host} | ||
51 | database_port: ${secrets.mysql.port} | ||
52 | database_name: ${secrets.mysql.name} | ||
53 | database_user: ${secrets.mysql.user} | ||
54 | database_password: ${secrets.mysql.password} | ||
55 | database_server_version: ${pkgs.mariadb.mysqlVersion} | ||
56 | mailer_transport: sendmail | ||
57 | mailer_host: null | ||
58 | mailer_user: null | ||
59 | mailer_password: null | ||
60 | subscription_email: ${secrets.email} | ||
61 | allow_robots: true | ||
62 | secret: ${secrets.secret} | ||
63 | ''; | ||
64 | } | ||
65 | ]; | ||
66 | |||
67 | services.websites.env.integration.vhostConfs.connexionswing_dev = { | ||
68 | certName = "eldiron"; | ||
29 | addToCerts = true; | 69 | addToCerts = true; |
30 | hosts = ["connexionswing.immae.eu" "sandetludo.immae.eu" ]; | 70 | hosts = ["connexionswing.immae.eu" "sandetludo.immae.eu" ]; |
31 | root = connexionswing.apache.root; | 71 | root = pcfg.webappDirs.connexionswing_dev; |
32 | extraConfig = [ connexionswing.apache.vhostConf ]; | 72 | extraConfig = [ |
33 | }; | 73 | '' |
34 | services.filesWatcher.phpfpm-connexionswing_dev = { | 74 | <FilesMatch "\.php$"> |
35 | restart = true; | 75 | SetHandler "proxy:unix:${pcfg.phpListenPaths.connexionswing_dev}|fcgi://localhost" |
36 | paths = [ "/var/secrets/webapps/${connexionswing.app.environment}-connexionswing" ]; | 76 | </FilesMatch> |
77 | |||
78 | <Directory ${app.varDir}/medias> | ||
79 | Options FollowSymLinks | ||
80 | AllowOverride None | ||
81 | Require all granted | ||
82 | </Directory> | ||
83 | |||
84 | <Directory ${app.varDir}/uploads> | ||
85 | Options FollowSymLinks | ||
86 | AllowOverride None | ||
87 | Require all granted | ||
88 | </Directory> | ||
89 | |||
90 | <Location /> | ||
91 | Use LDAPConnect | ||
92 | Require ldap-group cn=connexionswing.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu | ||
93 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://connexionswing.com\"></html>" | ||
94 | </Location> | ||
95 | |||
96 | <Directory ${pcfg.webappDirs.connexionswing_dev}> | ||
97 | Options Indexes FollowSymLinks MultiViews Includes | ||
98 | AllowOverride None | ||
99 | Require all granted | ||
100 | |||
101 | DirectoryIndex app_dev.php | ||
102 | |||
103 | <IfModule mod_negotiation.c> | ||
104 | Options -MultiViews | ||
105 | </IfModule> | ||
106 | |||
107 | <IfModule mod_rewrite.c> | ||
108 | RewriteEngine On | ||
109 | |||
110 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ | ||
111 | RewriteRule ^(.*) - [E=BASE:%1] | ||
112 | |||
113 | # Maintenance script | ||
114 | RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f | ||
115 | RewriteCond %{SCRIPT_FILENAME} !maintenance.php | ||
116 | RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L] | ||
117 | ErrorDocument 503 /maintenance.php | ||
118 | |||
119 | # Sets the HTTP_AUTHORIZATION header removed by Apache | ||
120 | RewriteCond %{HTTP:Authorization} . | ||
121 | RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | ||
122 | |||
123 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ | ||
124 | RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] | ||
125 | |||
126 | # If the requested filename exists, simply serve it. | ||
127 | # We only want to let Apache serve files and not directories. | ||
128 | RewriteCond %{REQUEST_FILENAME} -f | ||
129 | RewriteRule ^ - [L] | ||
130 | |||
131 | # Rewrite all other queries to the front controller. | ||
132 | RewriteRule ^ %{ENV:BASE}/app_dev.php [L] | ||
133 | </IfModule> | ||
134 | |||
135 | </Directory> | ||
136 | '' | ||
137 | ]; | ||
37 | }; | 138 | }; |
38 | }; | 139 | }; |
39 | } | 140 | } |
40 | |||
diff --git a/modules/private/websites/florian/app.nix b/modules/private/websites/florian/app.nix index 5ce073a..3f44ec4 100644 --- a/modules/private/websites/florian/app.nix +++ b/modules/private/websites/florian/app.nix | |||
@@ -41,7 +41,7 @@ in { | |||
41 | { | 41 | { |
42 | dest = "webapps/${app.environment}-tellesflorian-passwords"; | 42 | dest = "webapps/${app.environment}-tellesflorian-passwords"; |
43 | user = config.services.httpd.Inte.user; | 43 | user = config.services.httpd.Inte.user; |
44 | group = config.services.httpd.Inte.user; | 44 | group = config.services.httpd.Inte.group; |
45 | permissions = "0400"; | 45 | permissions = "0400"; |
46 | text = '' | 46 | text = '' |
47 | invite:${secrets.invite_passwords} | 47 | invite:${secrets.invite_passwords} |
@@ -50,7 +50,7 @@ in { | |||
50 | { | 50 | { |
51 | dest = "webapps/${app.environment}-tellesflorian"; | 51 | dest = "webapps/${app.environment}-tellesflorian"; |
52 | user = config.services.httpd.Inte.user; | 52 | user = config.services.httpd.Inte.user; |
53 | group = config.services.httpd.Inte.user; | 53 | group = config.services.httpd.Inte.group; |
54 | permissions = "0400"; | 54 | permissions = "0400"; |
55 | text = '' | 55 | text = '' |
56 | # This file is auto-generated during the composer install | 56 | # This file is auto-generated during the composer install |
diff --git a/modules/private/websites/ludivinecassal/integration.nix b/modules/private/websites/ludivinecassal/integration.nix index bc05d9b..55f2432 100644 --- a/modules/private/websites/ludivinecassal/integration.nix +++ b/modules/private/websites/ludivinecassal/integration.nix | |||
@@ -1,36 +1,139 @@ | |||
1 | { lib, pkgs, config, myconfig, ... }: | 1 | { lib, pkgs, config, myconfig, ... }: |
2 | let | 2 | let |
3 | ludivinecassal = pkgs.callPackage ./builder.nix { | 3 | secrets = myconfig.env.websites.ludivinecassal.integration; |
4 | inherit (pkgs.webapps) ludivinecassal; | 4 | app = pkgs.webapps.ludivinecassal.override { environment = secrets.environment; }; |
5 | config = myconfig.env.websites.ludivinecassal.integration; | ||
6 | apacheUser = config.services.httpd.Inte.user; | ||
7 | apacheGroup = config.services.httpd.Inte.group; | ||
8 | }; | ||
9 | |||
10 | cfg = config.myServices.websites.ludivinecassal.integration; | 5 | cfg = config.myServices.websites.ludivinecassal.integration; |
6 | pcfg = config.services.phpApplication; | ||
11 | in { | 7 | in { |
12 | options.myServices.websites.ludivinecassal.integration.enable = lib.mkEnableOption "enable Ludivine's website in integration"; | 8 | options.myServices.websites.ludivinecassal.integration.enable = lib.mkEnableOption "enable Ludivine's website in integration"; |
13 | 9 | ||
14 | config = lib.mkIf cfg.enable { | 10 | config = lib.mkIf cfg.enable { |
15 | secrets.keys = ludivinecassal.keys; | 11 | services.phpApplication.apps.ludivinecassal_dev = { |
16 | 12 | websiteEnv = "integration"; | |
17 | systemd.services.phpfpm-ludivinecassal_dev.after = lib.mkAfter ludivinecassal.phpFpm.serviceDeps; | 13 | httpdUser = config.services.httpd.Inte.user; |
18 | systemd.services.phpfpm-ludivinecassal_dev.wants = ludivinecassal.phpFpm.serviceDeps; | 14 | httpdGroup = config.services.httpd.Inte.group; |
19 | systemd.services.phpfpm-ludivinecassal_dev.preStart = lib.mkAfter ludivinecassal.phpFpm.preStart; | 15 | inherit (app) webRoot varDir; |
20 | services.phpfpm.poolConfigs.ludivinecassal_dev = ludivinecassal.phpFpm.pool; | 16 | varDirPaths = { |
21 | system.activationScripts.ludivinecassal_dev = ludivinecassal.activationScript; | 17 | "tmp" = "0700"; |
22 | myServices.websites.webappDirs."${ludivinecassal.apache.webappName}" = ludivinecassal.app.webRoot; | 18 | }; |
23 | services.websites.env.integration.modules = ludivinecassal.apache.modules; | 19 | inherit app; |
24 | services.websites.env.integration.vhostConfs.ludivine = { | 20 | serviceDeps = [ "mysql.service" ]; |
25 | certName = "eldiron"; | 21 | preStartActions = [ |
22 | "./bin/console --env=${app.environment} cache:clear --no-warmup" | ||
23 | ]; | ||
24 | phpOpenbasedir = [ "/tmp" ]; | ||
25 | phpPool = '' | ||
26 | php_admin_value[upload_max_filesize] = 20M | ||
27 | php_admin_value[post_max_size] = 20M | ||
28 | ;php_admin_flag[log_errors] = on | ||
29 | pm = ondemand | ||
30 | pm.max_children = 5 | ||
31 | pm.process_idle_timeout = 60 | ||
32 | env[SYMFONY_DEBUG_MODE] = "yes" | ||
33 | ''; | ||
34 | phpWatchFiles = [ | ||
35 | config.secrets.fullPaths."webapps/${app.environment}-ludivinecassal" | ||
36 | ]; | ||
37 | }; | ||
38 | |||
39 | secrets.keys = [ | ||
40 | { | ||
41 | dest = "webapps/${app.environment}-ludivinecassal"; | ||
42 | user = config.services.httpd.Inte.user; | ||
43 | group = config.services.httpd.Inte.group; | ||
44 | permissions = "0400"; | ||
45 | text = '' | ||
46 | # This file is auto-generated during the composer install | ||
47 | parameters: | ||
48 | database_host: ${secrets.mysql.host} | ||
49 | database_port: ${secrets.mysql.port} | ||
50 | database_name: ${secrets.mysql.name} | ||
51 | database_user: ${secrets.mysql.user} | ||
52 | database_password: ${secrets.mysql.password} | ||
53 | database_server_version: ${pkgs.mariadb.mysqlVersion} | ||
54 | mailer_transport: smtp | ||
55 | mailer_host: 127.0.0.1 | ||
56 | mailer_user: null | ||
57 | mailer_password: null | ||
58 | secret: ${secrets.secret} | ||
59 | ldap_host: ldap.immae.eu | ||
60 | ldap_port: 636 | ||
61 | ldap_version: 3 | ||
62 | ldap_ssl: true | ||
63 | ldap_tls: false | ||
64 | ldap_user_bind: 'uid={username},ou=users,dc=immae,dc=eu' | ||
65 | ldap_base_dn: 'dc=immae,dc=eu' | ||
66 | ldap_search_dn: '${secrets.ldap.dn}' | ||
67 | ldap_search_password: '${secrets.ldap.password}' | ||
68 | ldap_search_filter: '${secrets.ldap.search}' | ||
69 | leapt_im: | ||
70 | binary_path: ${pkgs.imagemagick}/bin | ||
71 | assetic: | ||
72 | sass: ${pkgs.sass}/bin/sass | ||
73 | ruby: ${pkgs.ruby}/bin/ruby | ||
74 | ''; | ||
75 | } | ||
76 | ]; | ||
77 | |||
78 | services.websites.env.integration.vhostConfs.ludivinecassal_dev = { | ||
79 | certName = "eldiron"; | ||
26 | addToCerts = true; | 80 | addToCerts = true; |
27 | hosts = [ "ludivine.immae.eu" ]; | 81 | hosts = [ "ludivine.immae.eu" ]; |
28 | root = ludivinecassal.apache.root; | 82 | root = pcfg.webappDirs.ludivinecassal_dev; |
29 | extraConfig = [ ludivinecassal.apache.vhostConf ]; | 83 | extraConfig = [ |
30 | }; | 84 | '' |
31 | services.filesWatcher.phpfpm-ludivinecassal_dev = { | 85 | <FilesMatch "\.php$"> |
32 | restart = true; | 86 | SetHandler "proxy:unix:${pcfg.phpListenPaths.ludivinecassal_dev}|fcgi://localhost" |
33 | paths = [ "/var/secrets/webapps/${ludivinecassal.app.environment}-ludivinecassal" ]; | 87 | </FilesMatch> |
88 | |||
89 | <Location /> | ||
90 | Use LDAPConnect | ||
91 | Require ldap-group cn=ludivine.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu | ||
92 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://ludivinecassal.com\"></html>" | ||
93 | </Location> | ||
94 | |||
95 | <Directory ${pcfg.webappDirs.ludivinecassal_dev}> | ||
96 | Options Indexes FollowSymLinks MultiViews Includes | ||
97 | AllowOverride None | ||
98 | Require all granted | ||
99 | |||
100 | DirectoryIndex app_dev.php | ||
101 | |||
102 | <IfModule mod_negotiation.c> | ||
103 | Options -MultiViews | ||
104 | </IfModule> | ||
105 | |||
106 | <IfModule mod_rewrite.c> | ||
107 | RewriteEngine On | ||
108 | |||
109 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ | ||
110 | RewriteRule ^(.*) - [E=BASE:%1] | ||
111 | |||
112 | # Maintenance script | ||
113 | RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f | ||
114 | RewriteCond %{SCRIPT_FILENAME} !maintenance.php | ||
115 | RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L] | ||
116 | ErrorDocument 503 /maintenance.php | ||
117 | |||
118 | # Sets the HTTP_AUTHORIZATION header removed by Apache | ||
119 | RewriteCond %{HTTP:Authorization} . | ||
120 | RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | ||
121 | |||
122 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ | ||
123 | RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] | ||
124 | |||
125 | # If the requested filename exists, simply serve it. | ||
126 | # We only want to let Apache serve files and not directories. | ||
127 | RewriteCond %{REQUEST_FILENAME} -f | ||
128 | RewriteRule ^ - [L] | ||
129 | |||
130 | # Rewrite all other queries to the front controller. | ||
131 | RewriteRule ^ %{ENV:BASE}/app_dev.php [L] | ||
132 | </IfModule> | ||
133 | |||
134 | </Directory> | ||
135 | '' | ||
136 | ]; | ||
34 | }; | 137 | }; |
35 | }; | 138 | }; |
36 | } | 139 | } |
diff --git a/modules/private/websites/piedsjaloux/integration.nix b/modules/private/websites/piedsjaloux/integration.nix index 8007c91..0a33bc0 100644 --- a/modules/private/websites/piedsjaloux/integration.nix +++ b/modules/private/websites/piedsjaloux/integration.nix | |||
@@ -1,32 +1,128 @@ | |||
1 | { lib, pkgs, config, myconfig, ... }: | 1 | { lib, pkgs, config, myconfig, ... }: |
2 | let | 2 | let |
3 | piedsjaloux = pkgs.callPackage ./builder.nix { | 3 | secrets = myconfig.env.websites.piedsjaloux.integration; |
4 | inherit (pkgs.webapps) piedsjaloux; | 4 | app = pkgs.webapps.piedsjaloux.override { environment = secrets.environment; }; |
5 | config = myconfig.env.websites.piedsjaloux.integration; | ||
6 | apacheUser = config.services.httpd.Inte.user; | ||
7 | apacheGroup = config.services.httpd.Inte.group; | ||
8 | }; | ||
9 | |||
10 | cfg = config.myServices.websites.piedsjaloux.integration; | 5 | cfg = config.myServices.websites.piedsjaloux.integration; |
6 | pcfg = config.services.phpApplication; | ||
11 | in { | 7 | in { |
12 | options.myServices.websites.piedsjaloux.integration.enable = lib.mkEnableOption "enable PiedsJaloux's website in integration"; | 8 | options.myServices.websites.piedsjaloux.integration.enable = lib.mkEnableOption "enable PiedsJaloux's website in integration"; |
13 | 9 | ||
14 | config = lib.mkIf cfg.enable { | 10 | config = lib.mkIf cfg.enable { |
15 | secrets.keys = piedsjaloux.keys; | 11 | services.phpApplication.apps.piedsjaloux_dev = { |
16 | systemd.services.phpfpm-piedsjaloux_dev.after = lib.mkAfter piedsjaloux.phpFpm.serviceDeps; | 12 | websiteEnv = "integration"; |
17 | systemd.services.phpfpm-piedsjaloux_dev.wants = piedsjaloux.phpFpm.serviceDeps; | 13 | httpdUser = config.services.httpd.Inte.user; |
18 | systemd.services.phpfpm-piedsjaloux_dev.preStart = lib.mkAfter piedsjaloux.phpFpm.preStart; | 14 | httpdGroup = config.services.httpd.Inte.group; |
19 | services.phpfpm.poolConfigs.piedsjaloux_dev = piedsjaloux.phpFpm.pool; | 15 | inherit (app) webRoot varDir; |
20 | system.activationScripts.piedsjaloux_dev = piedsjaloux.activationScript; | 16 | varDirPaths = { |
21 | myServices.websites.webappDirs."${piedsjaloux.apache.webappName}" = piedsjaloux.app.webRoot; | 17 | "tmp" = "0700"; |
22 | services.websites.env.integration.modules = piedsjaloux.apache.modules; | 18 | }; |
23 | services.websites.env.integration.vhostConfs.piedsjaloux = { | 19 | inherit app; |
24 | certName = "eldiron"; | 20 | serviceDeps = [ "mysql.service" ]; |
21 | preStartActions = [ | ||
22 | "./bin/console --env=${app.environment} cache:clear --no-warmup" | ||
23 | ]; | ||
24 | phpOpenbasedir = [ "/tmp" ]; | ||
25 | phpPool = '' | ||
26 | php_admin_value[upload_max_filesize] = 20M | ||
27 | php_admin_value[post_max_size] = 20M | ||
28 | ;php_admin_flag[log_errors] = on | ||
29 | env[PATH] = ${lib.makeBinPath [ pkgs.apg pkgs.unzip ]} | ||
30 | pm = ondemand | ||
31 | pm.max_children = 5 | ||
32 | pm.process_idle_timeout = 60 | ||
33 | env[SYMFONY_DEBUG_MODE] = "yes" | ||
34 | ''; | ||
35 | phpWatchFiles = [ | ||
36 | config.secrets.fullPaths."webapps/${app.environment}-piedsjaloux" | ||
37 | ]; | ||
38 | }; | ||
39 | |||
40 | secrets.keys = [ | ||
41 | { | ||
42 | dest = "webapps/${app.environment}-piedsjaloux"; | ||
43 | user = config.services.httpd.Inte.user; | ||
44 | group = config.services.httpd.Inte.group; | ||
45 | permissions = "0400"; | ||
46 | text = '' | ||
47 | # This file is auto-generated during the composer install | ||
48 | parameters: | ||
49 | database_host: ${secrets.mysql.host} | ||
50 | database_port: ${secrets.mysql.port} | ||
51 | database_name: ${secrets.mysql.name} | ||
52 | database_user: ${secrets.mysql.user} | ||
53 | database_password: ${secrets.mysql.password} | ||
54 | database_server_version: ${pkgs.mariadb.mysqlVersion} | ||
55 | mailer_transport: smtp | ||
56 | mailer_host: 127.0.0.1 | ||
57 | mailer_user: null | ||
58 | mailer_password: null | ||
59 | secret: ${secrets.secret} | ||
60 | pdflatex: "${pkgs.texlive.combine { inherit (pkgs.texlive) attachfile preprint scheme-small; }}/bin/pdflatex" | ||
61 | leapt_im: | ||
62 | binary_path: ${pkgs.imagemagick}/bin | ||
63 | ''; | ||
64 | } | ||
65 | ]; | ||
66 | |||
67 | services.websites.env.integration.vhostConfs.piedsjaloux_dev = { | ||
68 | certName = "eldiron"; | ||
25 | addToCerts = true; | 69 | addToCerts = true; |
26 | hosts = [ "piedsjaloux.immae.eu" ]; | 70 | hosts = [ "piedsjaloux.immae.eu" ]; |
27 | root = piedsjaloux.apache.root; | 71 | root = pcfg.webappDirs.piedsjaloux_dev; |
28 | extraConfig = [ piedsjaloux.apache.vhostConf ]; | 72 | extraConfig = [ |
73 | '' | ||
74 | <FilesMatch "\.php$"> | ||
75 | SetHandler "proxy:unix:${pcfg.phpListenPaths.piedsjaloux_dev}|fcgi://localhost" | ||
76 | </FilesMatch> | ||
77 | |||
78 | <Location /> | ||
79 | Use LDAPConnect | ||
80 | Require ldap-group cn=piedsjaloux.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu | ||
81 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://piedsjaloux.fr\"></html>" | ||
82 | </Location> | ||
83 | |||
84 | <Directory ${pcfg.webappDirs.piedsjaloux_dev}> | ||
85 | Options Indexes FollowSymLinks MultiViews Includes | ||
86 | AllowOverride None | ||
87 | Require all granted | ||
88 | |||
89 | DirectoryIndex app_dev.php | ||
90 | |||
91 | <IfModule mod_negotiation.c> | ||
92 | Options -MultiViews | ||
93 | </IfModule> | ||
94 | |||
95 | <IfModule mod_rewrite.c> | ||
96 | RewriteEngine On | ||
97 | |||
98 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ | ||
99 | RewriteRule ^(.*) - [E=BASE:%1] | ||
100 | |||
101 | # Maintenance script | ||
102 | RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f | ||
103 | RewriteCond %{SCRIPT_FILENAME} !maintenance.php | ||
104 | RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L] | ||
105 | ErrorDocument 503 /maintenance.php | ||
106 | |||
107 | # Sets the HTTP_AUTHORIZATION header removed by Apache | ||
108 | RewriteCond %{HTTP:Authorization} . | ||
109 | RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | ||
110 | |||
111 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ | ||
112 | RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] | ||
113 | |||
114 | # If the requested filename exists, simply serve it. | ||
115 | # We only want to let Apache serve files and not directories. | ||
116 | RewriteCond %{REQUEST_FILENAME} -f | ||
117 | RewriteRule ^ - [L] | ||
118 | |||
119 | # Rewrite all other queries to the front controller. | ||
120 | RewriteRule ^ %{ENV:BASE}/app_dev.php [L] | ||
121 | </IfModule> | ||
122 | |||
123 | </Directory> | ||
124 | '' | ||
125 | ]; | ||
29 | }; | 126 | }; |
30 | }; | 127 | }; |
31 | } | 128 | } |
32 | |||