diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-01-29 08:33:53 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-01-29 08:34:48 +0100 |
commit | d578d27021abba83de60143611230c692da46521 (patch) | |
tree | 87479b7ca9cc376d6aa3e32884b60afee6c6c7f1 /nixops/modules/websites/ftp/jerome.nix | |
parent | 439049e58f9638eefaf1648b1898fdb1d964d97e (diff) | |
download | Nix-d578d27021abba83de60143611230c692da46521.tar.gz Nix-d578d27021abba83de60143611230c692da46521.tar.zst Nix-d578d27021abba83de60143611230c692da46521.zip |
Add Jerome's ftp website
Related issue: https://git.immae.eu/mantisbt/view.php?id=77
Diffstat (limited to 'nixops/modules/websites/ftp/jerome.nix')
-rw-r--r-- | nixops/modules/websites/ftp/jerome.nix | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/nixops/modules/websites/ftp/jerome.nix b/nixops/modules/websites/ftp/jerome.nix new file mode 100644 index 0000000..199bfab --- /dev/null +++ b/nixops/modules/websites/ftp/jerome.nix | |||
@@ -0,0 +1,96 @@ | |||
1 | { lib, pkgs, config, myconfig, mylibs, ... }: | ||
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 | |||
14 | imports = [ | ||
15 | ../commons/stats.nix | ||
16 | ]; | ||
17 | |||
18 | config = lib.mkIf cfg.production.enable { | ||
19 | services.myWebsites.commons.stats.enable = true; | ||
20 | services.myWebsites.commons.stats.sites = [ | ||
21 | { | ||
22 | name = "naturaloutil.immae.eu"; | ||
23 | conf = ./jerome_goaccess.conf; | ||
24 | } | ||
25 | ]; | ||
26 | |||
27 | security.acme.certs."ftp".extraDomains."naturaloutil.immae.eu" = null; | ||
28 | security.acme.certs."naturaloutil" = config.services.myCertificates.certConfig // { | ||
29 | domain = "naturaloutil.immae.eu"; | ||
30 | }; | ||
31 | |||
32 | services.myPhpfpm.poolConfigs.jerome = let | ||
33 | configFile = pkgs.writeText "naturaloutil.inc.php" '' | ||
34 | <?php | ||
35 | $mysql_user = '${env.mysql.user}' ; | ||
36 | $mysql_server = '${env.mysql.host}' ; | ||
37 | $mysql_base = '${env.mysql.name}' ; | ||
38 | $mysql_password = '${env.mysql.password}' ; | ||
39 | //connect to db | ||
40 | $db = mysqli_init(); | ||
41 | ${if env.mysql.host != "localhost" then '' | ||
42 | mysqli_options ($db, MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, true); | ||
43 | $db->ssl_set(NULL, NULL, "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt", NULL, NULL); | ||
44 | '' else ""} | ||
45 | $database = connect_db($db, $mysql_server, $mysql_base, $mysql_user, $mysql_password); | ||
46 | ?> | ||
47 | ''; | ||
48 | in '' | ||
49 | listen = /run/phpfpm/naturaloutil.sock | ||
50 | user = wwwrun | ||
51 | group = wwwrun | ||
52 | listen.owner = wwwrun | ||
53 | listen.group = wwwrun | ||
54 | |||
55 | pm = ondemand | ||
56 | pm.max_children = 5 | ||
57 | pm.process_idle_timeout = 60 | ||
58 | |||
59 | env[BDD_CONNECT] = "${configFile}" | ||
60 | php_admin_value[open_basedir] = "${configFile}:${varDir}:/tmp" | ||
61 | ''; | ||
62 | services.myPhpfpm.poolPhpConfigs.jerome = '' | ||
63 | extension=${pkgs.php}/lib/php/extensions/mysqli.so | ||
64 | ''; | ||
65 | services.myWebsites.production.modules = adminer.apache.modules ++ [ "proxy_fcgi" ]; | ||
66 | services.myWebsites.production.vhostConfs.naturaloutil = { | ||
67 | certName = "naturaloutil"; | ||
68 | hosts = ["naturaloutil.immae.eu" ]; | ||
69 | root = varDir; | ||
70 | extraConfig = [ | ||
71 | adminer.apache.vhostConf | ||
72 | '' | ||
73 | Use Stats naturaloutil.immae.eu | ||
74 | ServerAdmin ${env.server_admin} | ||
75 | ErrorLog "${varDir}/logs/error_log" | ||
76 | CustomLog "${varDir}/logs/access_log" combined | ||
77 | |||
78 | <FilesMatch "\.php$"> | ||
79 | SetHandler "proxy:unix:/run/phpfpm/naturaloutil.sock|fcgi://localhost" | ||
80 | </FilesMatch> | ||
81 | |||
82 | <Directory ${varDir}/logs> | ||
83 | AllowOverride None | ||
84 | Require all denied | ||
85 | </Directory> | ||
86 | <Directory ${varDir}> | ||
87 | DirectoryIndex index.php index.htm index.html | ||
88 | Options Indexes FollowSymLinks MultiViews Includes | ||
89 | AllowOverride None | ||
90 | Require all granted | ||
91 | </Directory> | ||
92 | '' | ||
93 | ]; | ||
94 | }; | ||
95 | }; | ||
96 | } | ||