]>
Commit | Line | Data |
---|---|---|
ab8f306d | 1 | { lib, pkgs, config, ... }: |
f8026b6e | 2 | let |
d3452fc5 IB |
3 | secrets = config.myEnv.websites.ludivine.integration; |
4 | app = pkgs.callPackage ./app { | |
dcac3ec7 | 5 | composerEnv = pkgs.composerEnv.override { php = pkgs.php72; }; |
d3452fc5 IB |
6 | environment = secrets.environment; |
7 | varDir = "/var/lib/ludivine_integration"; | |
8 | secretsPath = config.secrets.fullPaths."websites/ludivine/integration"; | |
9 | }; | |
10 | cfg = config.myServices.websites.ludivine.integration; | |
9f66adf4 | 11 | pcfg = config.services.phpApplication; |
f8026b6e | 12 | in { |
d3452fc5 | 13 | options.myServices.websites.ludivine.integration.enable = lib.mkEnableOption "enable Ludivine's website in integration"; |
f8026b6e IB |
14 | |
15 | config = lib.mkIf cfg.enable { | |
d3452fc5 IB |
16 | services.duplyBackup.profiles.ludivine_integration.rootDir = app.varDir; |
17 | services.phpApplication.apps.ludivine_integration = { | |
9f66adf4 IB |
18 | websiteEnv = "integration"; |
19 | httpdUser = config.services.httpd.Inte.user; | |
20 | httpdGroup = config.services.httpd.Inte.group; | |
21 | inherit (app) webRoot varDir; | |
22 | varDirPaths = { | |
23 | "tmp" = "0700"; | |
24 | }; | |
25 | inherit app; | |
26 | serviceDeps = [ "mysql.service" ]; | |
27 | preStartActions = [ | |
28 | "./bin/console --env=${app.environment} cache:clear --no-warmup" | |
29 | ]; | |
30 | phpOpenbasedir = [ "/tmp" ]; | |
5400b9b6 IB |
31 | phpPool = { |
32 | "php_admin_value[upload_max_filesize]" = "20M"; | |
33 | "php_admin_value[post_max_size]" = "20M"; | |
34 | #"php_admin_flag[log_errors]" = "on"; | |
35 | "pm" = "ondemand"; | |
36 | "pm.max_children" = "5"; | |
37 | "pm.process_idle_timeout" = "60"; | |
38 | }; | |
39 | phpEnv = { | |
d3452fc5 IB |
40 | PATH = lib.makeBinPath [ |
41 | # below ones don't need to be in the PATH but they’re used in | |
42 | # secrets | |
43 | pkgs.imagemagick pkgs.sass pkgs.ruby | |
44 | ]; | |
45 | SYMFONY_DEBUG_MODE = "\"yes\""; | |
5400b9b6 | 46 | }; |
9f66adf4 | 47 | phpWatchFiles = [ |
d3452fc5 | 48 | config.secrets.fullPaths."websites/ludivine/integration" |
9f66adf4 | 49 | ]; |
dcac3ec7 | 50 | phpPackage = pkgs.php72; |
9f66adf4 IB |
51 | }; |
52 | ||
53 | secrets.keys = [ | |
54 | { | |
d3452fc5 | 55 | dest = "websites/ludivine/integration"; |
9f66adf4 IB |
56 | user = config.services.httpd.Inte.user; |
57 | group = config.services.httpd.Inte.group; | |
58 | permissions = "0400"; | |
59 | text = '' | |
60 | # This file is auto-generated during the composer install | |
61 | parameters: | |
62 | database_host: ${secrets.mysql.host} | |
63 | database_port: ${secrets.mysql.port} | |
ab8f306d | 64 | database_name: ${secrets.mysql.database} |
9f66adf4 IB |
65 | database_user: ${secrets.mysql.user} |
66 | database_password: ${secrets.mysql.password} | |
67 | database_server_version: ${pkgs.mariadb.mysqlVersion} | |
68 | mailer_transport: smtp | |
69 | mailer_host: 127.0.0.1 | |
70 | mailer_user: null | |
71 | mailer_password: null | |
72 | secret: ${secrets.secret} | |
73 | ldap_host: ldap.immae.eu | |
74 | ldap_port: 636 | |
75 | ldap_version: 3 | |
76 | ldap_ssl: true | |
77 | ldap_tls: false | |
78 | ldap_user_bind: 'uid={username},ou=users,dc=immae,dc=eu' | |
79 | ldap_base_dn: 'dc=immae,dc=eu' | |
80 | ldap_search_dn: '${secrets.ldap.dn}' | |
81 | ldap_search_password: '${secrets.ldap.password}' | |
ab8f306d | 82 | ldap_search_filter: '${secrets.ldap.filter}' |
9f66adf4 IB |
83 | leapt_im: |
84 | binary_path: ${pkgs.imagemagick}/bin | |
85 | assetic: | |
86 | sass: ${pkgs.sass}/bin/sass | |
87 | ruby: ${pkgs.ruby}/bin/ruby | |
88 | ''; | |
89 | } | |
90 | ]; | |
91 | ||
d3452fc5 IB |
92 | services.websites.env.integration.vhostConfs.ludivine_integration = { |
93 | certName = "integration"; | |
f8026b6e IB |
94 | addToCerts = true; |
95 | hosts = [ "ludivine.immae.eu" ]; | |
d3452fc5 | 96 | root = pcfg.webappDirs.ludivine_integration; |
9f66adf4 IB |
97 | extraConfig = [ |
98 | '' | |
99 | <FilesMatch "\.php$"> | |
d3452fc5 | 100 | SetHandler "proxy:unix:${pcfg.phpListenPaths.ludivine_integration}|fcgi://localhost" |
9f66adf4 IB |
101 | </FilesMatch> |
102 | ||
103 | <Location /> | |
104 | Use LDAPConnect | |
105 | Require ldap-group cn=ludivine.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu | |
106 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://ludivinecassal.com\"></html>" | |
107 | </Location> | |
108 | ||
d3452fc5 | 109 | <Directory ${pcfg.webappDirs.ludivine_integration}> |
9f66adf4 IB |
110 | Options Indexes FollowSymLinks MultiViews Includes |
111 | AllowOverride None | |
112 | Require all granted | |
113 | ||
114 | DirectoryIndex app_dev.php | |
115 | ||
116 | <IfModule mod_negotiation.c> | |
117 | Options -MultiViews | |
118 | </IfModule> | |
119 | ||
120 | <IfModule mod_rewrite.c> | |
121 | RewriteEngine On | |
122 | ||
123 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ | |
124 | RewriteRule ^(.*) - [E=BASE:%1] | |
125 | ||
126 | # Maintenance script | |
127 | RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f | |
128 | RewriteCond %{SCRIPT_FILENAME} !maintenance.php | |
129 | RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L] | |
130 | ErrorDocument 503 /maintenance.php | |
131 | ||
132 | # Sets the HTTP_AUTHORIZATION header removed by Apache | |
133 | RewriteCond %{HTTP:Authorization} . | |
134 | RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | |
135 | ||
136 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ | |
137 | RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] | |
138 | ||
139 | # If the requested filename exists, simply serve it. | |
140 | # We only want to let Apache serve files and not directories. | |
141 | RewriteCond %{REQUEST_FILENAME} -f | |
142 | RewriteRule ^ - [L] | |
143 | ||
144 | # Rewrite all other queries to the front controller. | |
145 | RewriteRule ^ %{ENV:BASE}/app_dev.php [L] | |
146 | </IfModule> | |
147 | ||
148 | </Directory> | |
149 | '' | |
150 | ]; | |
17f6eae9 | 151 | }; |
f8026b6e IB |
152 | }; |
153 | } |