diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-04-18 16:10:56 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2020-04-20 01:51:48 +0200 |
commit | d3452fc59b9839846225fd254926c64a9c71f071 (patch) | |
tree | a98a0958b826ac4b2ab137720edf0195c65dd958 /modules/private/websites/naturaloutil | |
parent | 514f9ec3beec470c4445be690673a0ceab9115b4 (diff) | |
download | Nix-d3452fc59b9839846225fd254926c64a9c71f071.tar.gz Nix-d3452fc59b9839846225fd254926c64a9c71f071.tar.zst Nix-d3452fc59b9839846225fd254926c64a9c71f071.zip |
Refactor websites
Diffstat (limited to 'modules/private/websites/naturaloutil')
-rw-r--r-- | modules/private/websites/naturaloutil/production.nix | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/modules/private/websites/naturaloutil/production.nix b/modules/private/websites/naturaloutil/production.nix deleted file mode 100644 index 1e79141..0000000 --- a/modules/private/websites/naturaloutil/production.nix +++ /dev/null | |||
@@ -1,97 +0,0 @@ | |||
1 | { lib, pkgs, config, ... }: | ||
2 | let | ||
3 | adminer = pkgs.callPackage ../commons/adminer.nix { inherit config; }; | ||
4 | cfg = config.myServices.websites.naturaloutil.production; | ||
5 | varDir = "/var/lib/ftp/jerome"; | ||
6 | env = config.myEnv.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.database}' ; | ||
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 | system.activationScripts.naturaloutil = { | ||
37 | deps = [ "httpd" ]; | ||
38 | text = '' | ||
39 | install -m 0755 -o wwwrun -g wwwrun -d /var/lib/php/sessions/naturaloutil | ||
40 | ''; | ||
41 | }; | ||
42 | systemd.services.phpfpm-jerome.after = lib.mkAfter [ "mysql.service" ]; | ||
43 | systemd.services.phpfpm-jerome.wants = [ "mysql.service" ]; | ||
44 | services.phpfpm.pools.jerome = { | ||
45 | user = "wwwrun"; | ||
46 | group = "wwwrun"; | ||
47 | settings = { | ||
48 | "listen.owner" = "wwwrun"; | ||
49 | "listen.group" = "wwwrun"; | ||
50 | |||
51 | "pm" = "ondemand"; | ||
52 | "pm.max_children" = "5"; | ||
53 | "pm.process_idle_timeout" = "60"; | ||
54 | |||
55 | "php_admin_value[open_basedir]" = "/var/lib/php/sessions/naturaloutil:/var/secrets/webapps/prod-naturaloutil:${varDir}:/tmp"; | ||
56 | "php_admin_value[session.save_path]" = "/var/lib/php/sessions/naturaloutil"; | ||
57 | }; | ||
58 | phpEnv = { | ||
59 | BDD_CONNECT = "/var/secrets/webapps/prod-naturaloutil"; | ||
60 | }; | ||
61 | phpOptions = config.services.phpfpm.phpOptions + '' | ||
62 | extension=${pkgs.php}/lib/php/extensions/mysqli.so | ||
63 | ''; | ||
64 | }; | ||
65 | services.websites.env.production.modules = adminer.apache.modules ++ [ "proxy_fcgi" ]; | ||
66 | services.websites.env.production.vhostConfs.naturaloutil = { | ||
67 | certName = "naturaloutil"; | ||
68 | certMainHost = "naturaloutil.immae.eu"; | ||
69 | hosts = ["naturaloutil.immae.eu" ]; | ||
70 | root = varDir; | ||
71 | extraConfig = [ | ||
72 | (adminer.apache.vhostConf null) | ||
73 | '' | ||
74 | Use Stats naturaloutil.immae.eu | ||
75 | ServerAdmin ${env.server_admin} | ||
76 | ErrorLog "${varDir}/logs/error_log" | ||
77 | CustomLog "${varDir}/logs/access_log" combined | ||
78 | |||
79 | <FilesMatch "\.php$"> | ||
80 | SetHandler "proxy:unix:${config.services.phpfpm.pools.jerome.socket}|fcgi://localhost" | ||
81 | </FilesMatch> | ||
82 | |||
83 | <Directory ${varDir}/logs> | ||
84 | AllowOverride None | ||
85 | Require all denied | ||
86 | </Directory> | ||
87 | <Directory ${varDir}> | ||
88 | DirectoryIndex index.php index.htm index.html | ||
89 | Options Indexes FollowSymLinks MultiViews Includes | ||
90 | AllowOverride None | ||
91 | Require all granted | ||
92 | </Directory> | ||
93 | '' | ||
94 | ]; | ||
95 | }; | ||
96 | }; | ||
97 | } | ||