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