]>
Commit | Line | Data |
---|---|---|
ab8f306d | 1 | { lib, pkgs, config, ... }: |
f8026b6e | 2 | let |
ab8f306d | 3 | secrets = config.myEnv.websites.piedsjaloux.integration; |
d3452fc5 IB |
4 | app = pkgs.callPackage ./app { |
5 | environment = secrets.environment; | |
6 | varDir = "/var/lib/piedsjaloux_integration"; | |
7 | secretsPath = config.secrets.fullPaths."websites/piedsjaloux/integration"; | |
8 | }; | |
f8026b6e | 9 | cfg = config.myServices.websites.piedsjaloux.integration; |
9f66adf4 | 10 | pcfg = config.services.phpApplication; |
d3452fc5 | 11 | texlive = pkgs.texlive.combine { inherit (pkgs.texlive) attachfile preprint scheme-small; }; |
f8026b6e IB |
12 | in { |
13 | options.myServices.websites.piedsjaloux.integration.enable = lib.mkEnableOption "enable PiedsJaloux's website in integration"; | |
14 | ||
15 | config = lib.mkIf cfg.enable { | |
d3452fc5 IB |
16 | services.duplyBackup.profiles.piedsjaloux_integration.rootDir = app.varDir; |
17 | services.phpApplication.apps.piedsjaloux_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 | pkgs.apg pkgs.unzip | |
42 | # below ones don't need to be in the PATH but they’re used in | |
43 | # secrets | |
44 | pkgs.imagemagick texlive | |
45 | ]; | |
46 | SYMFONY_DEBUG_MODE = "\"yes\""; | |
5400b9b6 | 47 | }; |
9f66adf4 | 48 | phpWatchFiles = [ |
d3452fc5 | 49 | app.secretsPath |
9f66adf4 IB |
50 | ]; |
51 | }; | |
52 | ||
53 | secrets.keys = [ | |
54 | { | |
d3452fc5 | 55 | dest = "websites/piedsjaloux/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} | |
d3452fc5 | 73 | pdflatex: "${texlive}/bin/pdflatex" |
9f66adf4 IB |
74 | leapt_im: |
75 | binary_path: ${pkgs.imagemagick}/bin | |
76 | ''; | |
77 | } | |
78 | ]; | |
79 | ||
d3452fc5 | 80 | services.websites.env.integration.vhostConfs.piedsjaloux_integration = { |
0f71cd76 | 81 | certName = "integration"; |
f8026b6e IB |
82 | addToCerts = true; |
83 | hosts = [ "piedsjaloux.immae.eu" ]; | |
d3452fc5 | 84 | root = pcfg.webappDirs.piedsjaloux_integration; |
9f66adf4 IB |
85 | extraConfig = [ |
86 | '' | |
87 | <FilesMatch "\.php$"> | |
d3452fc5 | 88 | SetHandler "proxy:unix:${pcfg.phpListenPaths.piedsjaloux_integration}|fcgi://localhost" |
9f66adf4 IB |
89 | </FilesMatch> |
90 | ||
91 | <Location /> | |
92 | Use LDAPConnect | |
93 | Require ldap-group cn=piedsjaloux.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu | |
94 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://piedsjaloux.fr\"></html>" | |
95 | </Location> | |
96 | ||
d3452fc5 | 97 | <Directory ${pcfg.webappDirs.piedsjaloux_integration}> |
9f66adf4 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 | '' | |
138 | ]; | |
f8026b6e IB |
139 | }; |
140 | }; | |
141 | } |