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