]>
Commit | Line | Data |
---|---|---|
ab8f306d | 1 | { lib, pkgs, config, ... }: |
2f0f1c48 | 2 | let |
c890321d | 3 | adminer = pkgs.callPackage ../commons/adminer.nix {}; |
ab8f306d | 4 | secrets = config.myEnv.websites.tellesflorian.integration; |
1594c8da | 5 | app = pkgs.webapps.tellesflorian.override { environment = secrets.environment; }; |
f8026b6e | 6 | cfg = config.myServices.websites.florian.app; |
1594c8da | 7 | pcfg = config.services.phpApplication; |
2f0f1c48 | 8 | in { |
f8026b6e | 9 | options.myServices.websites.florian.app.enable = lib.mkEnableOption "enable Florian's app in integration"; |
2f0f1c48 | 10 | |
f8026b6e | 11 | config = lib.mkIf cfg.enable { |
d2e703c5 | 12 | services.duplyBackup.profiles.tellesflorian_dev.rootDir = app.varDir; |
1594c8da IB |
13 | services.phpApplication.apps.florian_dev = { |
14 | websiteEnv = "integration"; | |
15 | httpdUser = config.services.httpd.Inte.user; | |
16 | httpdGroup = config.services.httpd.Inte.group; | |
17 | inherit (app) webRoot varDir; | |
18 | varDirPaths = { | |
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" ]; | |
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}-tellesflorian" | |
38 | ]; | |
39 | }; | |
40 | ||
41 | secrets.keys = [ | |
42 | { | |
43 | dest = "webapps/${app.environment}-tellesflorian-passwords"; | |
44 | user = config.services.httpd.Inte.user; | |
9f66adf4 | 45 | group = config.services.httpd.Inte.group; |
1594c8da IB |
46 | permissions = "0400"; |
47 | text = '' | |
48 | invite:${secrets.invite_passwords} | |
49 | ''; | |
50 | } | |
51 | { | |
52 | dest = "webapps/${app.environment}-tellesflorian"; | |
53 | user = config.services.httpd.Inte.user; | |
9f66adf4 | 54 | group = config.services.httpd.Inte.group; |
1594c8da IB |
55 | permissions = "0400"; |
56 | text = '' | |
57 | # This file is auto-generated during the composer install | |
58 | parameters: | |
59 | database_host: ${secrets.mysql.host} | |
60 | database_port: ${secrets.mysql.port} | |
ab8f306d | 61 | database_name: ${secrets.mysql.database} |
1594c8da IB |
62 | database_user: ${secrets.mysql.user} |
63 | database_password: ${secrets.mysql.password} | |
64 | mailer_transport: smtp | |
65 | mailer_host: 127.0.0.1 | |
66 | mailer_user: null | |
67 | mailer_password: null | |
68 | secret: ${secrets.secret} | |
69 | ''; | |
70 | } | |
71 | ]; | |
72 | ||
73 | services.websites.env.integration.modules = adminer.apache.modules; | |
74 | services.websites.env.integration.vhostConfs.florian_dev = { | |
0f71cd76 | 75 | certName = "integration"; |
7df420c2 | 76 | addToCerts = true; |
1594c8da IB |
77 | hosts = [ "app.tellesflorian.com" ]; |
78 | root = pcfg.webappDirs.florian_dev; | |
2f0f1c48 | 79 | extraConfig = [ |
1594c8da IB |
80 | '' |
81 | <FilesMatch "\.php$"> | |
82 | SetHandler "proxy:unix:${pcfg.phpListenPaths.florian_dev}|fcgi://localhost" | |
83 | </FilesMatch> | |
84 | ||
85 | <Location /> | |
86 | AuthBasicProvider file ldap | |
87 | Use LDAPConnect | |
88 | Require ldap-group cn=app.tellesflorian.com,cn=httpd,ou=services,dc=immae,dc=eu | |
89 | ||
90 | AuthUserFile "${config.secrets.fullPaths."webapps/${app.environment}-tellesflorian-passwords"}" | |
91 | Require user "invite" | |
92 | ||
93 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://tellesflorian.com\"></html>" | |
94 | </Location> | |
95 | ||
96 | <Directory ${pcfg.webappDirs.florian_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 | '' | |
2f0f1c48 IB |
137 | adminer.apache.vhostConf |
138 | ]; | |
139 | }; | |
140 | }; | |
141 | } |