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