]>
Commit | Line | Data |
---|---|---|
8a964143 | 1 | { lib, pkgs, config, myconfig, ... }: |
d578d270 IB |
2 | let |
3 | adminer = pkgs.callPackage ../commons/adminer.nix {}; | |
4 | cfg = config.services.myWebsites.Jerome; | |
5 | varDir = "/var/lib/ftp/jerome"; | |
6 | env = myconfig.env.websites.jerome; | |
7 | in { | |
8 | options.services.myWebsites.Jerome = { | |
9 | production = { | |
10 | enable = lib.mkEnableOption "enable Jerome's website"; | |
11 | }; | |
12 | }; | |
13 | ||
d578d270 | 14 | config = lib.mkIf cfg.production.enable { |
9eae2b47 | 15 | services.webstats.sites = [ { name = "naturaloutil.immae.eu"; } ]; |
d578d270 IB |
16 | |
17 | security.acme.certs."ftp".extraDomains."naturaloutil.immae.eu" = null; | |
18 | security.acme.certs."naturaloutil" = config.services.myCertificates.certConfig // { | |
19 | domain = "naturaloutil.immae.eu"; | |
20 | }; | |
21 | ||
1a718805 | 22 | secrets.keys = [{ |
1b3154e4 | 23 | dest = "webapps/prod-naturaloutil"; |
60dbbd12 IB |
24 | user = "wwwrun"; |
25 | group = "wwwrun"; | |
85f5ed68 | 26 | permissions = "0400"; |
60dbbd12 | 27 | text = '' |
d578d270 IB |
28 | <?php |
29 | $mysql_user = '${env.mysql.user}' ; | |
30 | $mysql_server = '${env.mysql.host}' ; | |
31 | $mysql_base = '${env.mysql.name}' ; | |
32 | $mysql_password = '${env.mysql.password}' ; | |
33 | //connect to db | |
34 | $db = mysqli_init(); | |
35 | ${if env.mysql.host != "localhost" then '' | |
36 | mysqli_options ($db, MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true); | |
37 | $db->ssl_set(NULL, NULL, "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt", NULL, NULL); | |
38 | '' else ""} | |
39 | $database = connect_db($db, $mysql_server, $mysql_base, $mysql_user, $mysql_password); | |
40 | ?> | |
60dbbd12 | 41 | ''; |
1b3154e4 IB |
42 | }]; |
43 | services.myPhpfpm.serviceDependencies.jerome = [ "mysql.service" ]; | |
60dbbd12 | 44 | services.myPhpfpm.poolConfigs.jerome = '' |
d578d270 IB |
45 | listen = /run/phpfpm/naturaloutil.sock |
46 | user = wwwrun | |
47 | group = wwwrun | |
48 | listen.owner = wwwrun | |
49 | listen.group = wwwrun | |
50 | ||
51 | pm = ondemand | |
52 | pm.max_children = 5 | |
53 | pm.process_idle_timeout = 60 | |
54 | ||
1b3154e4 IB |
55 | env[BDD_CONNECT] = "/var/secrets/webapps/prod-naturaloutil" |
56 | php_admin_value[open_basedir] = "/var/secrets/webapps/prod-naturaloutil:${varDir}:/tmp" | |
d578d270 IB |
57 | ''; |
58 | services.myPhpfpm.poolPhpConfigs.jerome = '' | |
59 | extension=${pkgs.php}/lib/php/extensions/mysqli.so | |
60 | ''; | |
61 | services.myWebsites.production.modules = adminer.apache.modules ++ [ "proxy_fcgi" ]; | |
62 | services.myWebsites.production.vhostConfs.naturaloutil = { | |
63 | certName = "naturaloutil"; | |
64 | hosts = ["naturaloutil.immae.eu" ]; | |
65 | root = varDir; | |
66 | extraConfig = [ | |
67 | adminer.apache.vhostConf | |
68 | '' | |
69 | Use Stats naturaloutil.immae.eu | |
70 | ServerAdmin ${env.server_admin} | |
71 | ErrorLog "${varDir}/logs/error_log" | |
72 | CustomLog "${varDir}/logs/access_log" combined | |
73 | ||
74 | <FilesMatch "\.php$"> | |
75 | SetHandler "proxy:unix:/run/phpfpm/naturaloutil.sock|fcgi://localhost" | |
76 | </FilesMatch> | |
77 | ||
78 | <Directory ${varDir}/logs> | |
79 | AllowOverride None | |
80 | Require all denied | |
81 | </Directory> | |
82 | <Directory ${varDir}> | |
83 | DirectoryIndex index.php index.htm index.html | |
84 | Options Indexes FollowSymLinks MultiViews Includes | |
85 | AllowOverride None | |
86 | Require all granted | |
87 | </Directory> | |
88 | '' | |
89 | ]; | |
90 | }; | |
91 | }; | |
92 | } |