]>
Commit | Line | Data |
---|---|---|
ab8f306d | 1 | { lib, pkgs, config, ... }: |
2f0f1c48 | 2 | let |
5400b9b6 | 3 | adminer = pkgs.callPackage ../commons/adminer.nix { inherit config; }; |
ab8f306d | 4 | secrets = config.myEnv.websites.tellesflorian.integration; |
41cce84a | 5 | webRoot = "/var/lib/ftp/immae/florian/web"; |
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 { |
d3452fc5 | 12 | services.phpApplication.apps.florian_app = { |
1594c8da IB |
13 | websiteEnv = "integration"; |
14 | httpdUser = config.services.httpd.Inte.user; | |
15 | httpdGroup = config.services.httpd.Inte.group; | |
41cce84a IB |
16 | inherit webRoot; |
17 | varDir = "/var/lib/ftp/immae/florian_var"; | |
1594c8da IB |
18 | varDirPaths = { |
19 | "var" = "0700"; | |
20 | }; | |
41cce84a | 21 | app = "/var/lib/ftp/immae/florian"; |
1594c8da IB |
22 | serviceDeps = [ "mysql.service" ]; |
23 | preStartActions = [ | |
41cce84a | 24 | "./bin/console --env=dev cache:clear --no-warmup" |
1594c8da IB |
25 | ]; |
26 | phpOpenbasedir = [ "/tmp" ]; | |
5400b9b6 IB |
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 | }; | |
35 | phpEnv = { | |
d3452fc5 | 36 | SYMFONY_DEBUG_MODE = "\"yes\""; |
5400b9b6 | 37 | }; |
1594c8da | 38 | phpWatchFiles = [ |
d3452fc5 | 39 | config.secrets.fullPaths."websites/florian/app" |
1594c8da | 40 | ]; |
dcac3ec7 | 41 | phpPackage = pkgs.php72; |
1594c8da IB |
42 | }; |
43 | ||
4c4652aa IB |
44 | secrets.keys = { |
45 | "websites/florian/app_passwords" = { | |
1594c8da | 46 | user = config.services.httpd.Inte.user; |
9f66adf4 | 47 | group = config.services.httpd.Inte.group; |
1594c8da IB |
48 | permissions = "0400"; |
49 | text = '' | |
50 | invite:${secrets.invite_passwords} | |
51 | ''; | |
4c4652aa IB |
52 | }; |
53 | "websites/florian/app" = { | |
1594c8da | 54 | user = config.services.httpd.Inte.user; |
9f66adf4 | 55 | group = config.services.httpd.Inte.group; |
1594c8da IB |
56 | permissions = "0400"; |
57 | text = '' | |
58 | # This file is auto-generated during the composer install | |
59 | parameters: | |
60 | database_host: ${secrets.mysql.host} | |
61 | database_port: ${secrets.mysql.port} | |
ab8f306d | 62 | database_name: ${secrets.mysql.database} |
1594c8da IB |
63 | database_user: ${secrets.mysql.user} |
64 | database_password: ${secrets.mysql.password} | |
65 | mailer_transport: smtp | |
66 | mailer_host: 127.0.0.1 | |
67 | mailer_user: null | |
68 | mailer_password: null | |
69 | secret: ${secrets.secret} | |
70 | ''; | |
4c4652aa IB |
71 | }; |
72 | }; | |
1594c8da IB |
73 | |
74 | services.websites.env.integration.modules = adminer.apache.modules; | |
d3452fc5 IB |
75 | services.websites.env.integration.vhostConfs.florian_app = { |
76 | certName = "integration"; | |
7df420c2 | 77 | addToCerts = true; |
1594c8da | 78 | hosts = [ "app.tellesflorian.com" ]; |
41cce84a | 79 | root = webRoot; |
2f0f1c48 | 80 | extraConfig = [ |
1594c8da IB |
81 | '' |
82 | <FilesMatch "\.php$"> | |
d3452fc5 | 83 | SetHandler "proxy:unix:${pcfg.phpListenPaths.florian_app}|fcgi://localhost" |
1594c8da IB |
84 | </FilesMatch> |
85 | ||
86 | <Location /> | |
87 | AuthBasicProvider file ldap | |
88 | Use LDAPConnect | |
89 | Require ldap-group cn=app.tellesflorian.com,cn=httpd,ou=services,dc=immae,dc=eu | |
90 | ||
d3452fc5 | 91 | AuthUserFile "${config.secrets.fullPaths."websites/florian/app_passwords"}" |
1594c8da IB |
92 | Require user "invite" |
93 | ||
94 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://tellesflorian.com\"></html>" | |
95 | </Location> | |
96 | ||
41cce84a | 97 | <Directory ${webRoot}> |
1594c8da IB |
98 | Options Indexes FollowSymLinks MultiViews Includes |
99 | AllowOverride None | |
100 | Require all granted | |
101 | ||
102 | DirectoryIndex app_dev.php | |
103 | ||
104 | <IfModule mod_negotiation.c> | |
105 | Options -MultiViews | |
106 | </IfModule> | |
107 | ||
108 | <IfModule mod_rewrite.c> | |
109 | RewriteEngine On | |
110 | ||
111 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ | |
112 | RewriteRule ^(.*) - [E=BASE:%1] | |
113 | ||
114 | # Maintenance script | |
115 | RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f | |
116 | RewriteCond %{SCRIPT_FILENAME} !maintenance.php | |
117 | RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L] | |
118 | ErrorDocument 503 /maintenance.php | |
119 | ||
120 | # Sets the HTTP_AUTHORIZATION header removed by Apache | |
121 | RewriteCond %{HTTP:Authorization} . | |
122 | RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | |
123 | ||
124 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ | |
125 | RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] | |
126 | ||
127 | # If the requested filename exists, simply serve it. | |
128 | # We only want to let Apache serve files and not directories. | |
129 | RewriteCond %{REQUEST_FILENAME} -f | |
130 | RewriteRule ^ - [L] | |
131 | ||
132 | # Rewrite all other queries to the front controller. | |
133 | RewriteRule ^ %{ENV:BASE}/app_dev.php [L] | |
134 | </IfModule> | |
135 | ||
136 | </Directory> | |
137 | '' | |
5400b9b6 | 138 | (adminer.apache.vhostConf null) |
2f0f1c48 IB |
139 | ]; |
140 | }; | |
141 | }; | |
142 | } |